ocaml-community / ocaml-mariadb

OCaml bindings to MariaDB, supporting the nonblocking API
55 stars 18 forks source link

Add integer tests #61

Closed tatchi closed 2 weeks ago

tatchi commented 1 month ago

This is based on https://github.com/ocaml-community/ocaml-mariadb/pull/60

I've added some tests in this PR related to integer encoding, to demonstrate the range of values supported, and to start a discussion on how to support 64-bit integer encoding.

As you can see from the tests, the current maximun supported value is Int32.max_int. Trying to insert e.g a Unsigned.UInt32.max_int value to an integer unsigned column or a Int.max_int to a bigint column fails.

I ran the same tests (in this branch) where I included https://github.com/ocaml-community/ocaml-mariadb/pull/54. In this case, the maximum value is Int.max_int and both examples above works fine. It still doesn't support 64 bits integer though.

So I finally tested it against https://github.com/ocaml-community/ocaml-mariadb/pull/43. I was able to insert (and read back) both Int64.max_int and Unsigned.UInt64.max_int (see commit). Unfortunately, it breaks two other tests:

test_txn

((2024-10-29 16:15:29.793594000+01:00)
 ("unhandled exception"
  ((monitor.ml.Error
    (Failure "field 'CAST(sum(i) AS integer)' is not an integer")
    ("Raised at Stdlib.failwith in file \"stdlib.ml\", line 29, characters 17-33"
     "Called from Nonblocking_testsuite.Make.test_txn.(fun) in file \"tests/nonblocking/nonblocking_testsuite.ml\", line 199, characters 36-55"
     "Called from Async_kernel__Deferred0.bind.(fun) in file \"src/deferred0.ml\", line 54, characters 64-69"
     "Called from Async_kernel__Job_queue.run_jobs in file \"src/job_queue.ml\", line 180, characters 6-47"
     "Caught by monitor main"))

test_many_select

Parameter (609520357 : int) came back as (609520357 : int64).

I don't know much about the low level C code, but from an end user perspective I'd say that:

paurkedal commented 3 weeks ago

I agree, and the additional tests will be very useful.