From c39cad18a200d29a3b3e84358932bdc87eaf8f24 Mon Sep 17 00:00:00 2001 From: zy C Date: Sat, 26 Sep 2026 00:54:50 -0700 Subject: [PATCH 1/3] refactor: change value Int constructor to Int64 of int64 Ordinary integers (entity ids in value position, tx ids, counts, journal days, epoch-ms numerics) now use Int64 of int64 instead of Int of int, eliminating 32-bit int overflow on Melange and removing the misuse of Instant for plain integers. - type: Int of int -> Int64 of int64; QueryFormInt of int -> int64 - equality/compare: Int64 vs Float numeric ordering, Int64 vs Instant comparable by magnitude but never equal (distinct semantics) - hashing: murmur3_hash_long for Int64 payloads - built-ins: exact int64 arithmetic; number?/integer? reject Instant; range emits int64 lists - parser: EDN ints parse via Int64.of_string; #inst -> Instant - codecs (sqlite + melange): Int64 -> Transit.Int64 unconditionally, Instant -> Transit.Date; decode accepts Int/Int64/Big_int and ~m tags for backwards compatibility - storage: normalize_stored_datom migrates legacy Instant values to Int64 unless the attr is db.type/instant (real dates preserved) - js facade: Yojson ints/Intlit -> Int64; Instant still prints as #inst/Intlit --- bench/bench_ocaml.ml | 8 +- bench/memory_scenario.ml | 14 +- bench/query_profile.ml | 8 +- examples/logseq_query_runner.ml | 13 +- examples/logseq_sqlite_storage.ml | 25 +- examples/sqlite_storage_example.ml | 2 +- impl/built_ins.ml | 170 ++- impl/built_ins.mli | 2 +- impl/data_readers.ml | 11 +- impl/datascript.ml | 46 +- impl/datascript.mli | 14 +- impl/db.ml | 17 +- impl/db.mli | 4 +- impl/entity.ml | 7 +- impl/parser.ml | 19 +- impl/pull_api.ml | 11 +- impl/pull_parser.ml | 12 +- impl/query.ml | 10 +- impl/query_eval.ml | 43 +- impl/query_where.ml | 6 +- impl/storage.ml | 15 +- impl/transact.ml | 16 +- impl/transact_datoms.ml | 10 +- impl/util.ml | 67 +- impl/util.mli | 4 + js/datascript_js.ml | 15 +- lg/datascript_lg.ml | 31 +- melange/datascript_melange_storage.ml | 17 +- sqlite/datascript_sqlite_codec.ml | 17 +- test/cross_runtime_ocaml.ml | 12 +- test/dune | 5 + test/js_smoke.ml | 4 +- test/sqlite_cross_runtime_native.ml | 6 +- test/test_built_ins.ml | 32 +- test/test_conn.ml | 24 +- test/test_core.ml | 4 +- test/test_datascript.ml | 1834 ++++++++++++------------- test/test_db.ml | 38 +- test/test_entity.ml | 8 +- test/test_int64.ml | 193 +++ test/test_issues.ml | 2 +- test/test_listen.ml | 6 +- test/test_logseq_query_planners.ml | 50 +- test/test_lookup_refs.ml | 34 +- test/test_parser.ml | 6 +- test/test_parser_find.ml | 4 +- test/test_parser_where.ml | 22 +- test/test_perf.ml | 6 +- test/test_pull_api.ml | 6 +- test/test_pull_parser.ml | 2 +- test/test_query_engine_fixes.ml | 34 +- test/test_query_namespace.ml | 110 +- test/test_query_pull.ml | 32 +- test/test_serialize.ml | 10 +- test/test_sqlite_storage.ml | 272 ++-- test/test_storage.ml | 8 +- test/test_tuples.ml | 18 +- test/test_upsert.ml | 104 +- test/test_util.ml | 10 +- type/datascript_types.ml | 4 +- 60 files changed, 1929 insertions(+), 1605 deletions(-) create mode 100644 test/test_int64.ml diff --git a/bench/bench_ocaml.ml b/bench/bench_ocaml.ml index 79d36c7..f316e3a 100644 --- a/bench/bench_ocaml.ml +++ b/bench/bench_ocaml.ml @@ -184,8 +184,8 @@ let random_man rng i = ; "full-name", One_value (String (name ^ " " ^ last_name)) ; "alias", Many_values alias_values ; "sex", One_value (Keyword (if next_int rng 2 = 0 then "male" else "female")) - ; "age", One_value (Int (next_int rng 100)) - ; "salary", One_value (Int (next_int rng 100_000)) + ; "age", One_value (Int64 (Int64.of_int (next_int rng 100))) + ; "salary", One_value (Int64 (Int64.of_int (next_int rng 100_000))) ] } @@ -255,7 +255,7 @@ let main () = bench config "q5-shortcircuit" (fun () -> consume_rows (q_string - ~inputs:[ Arg_scalar (Result_value (String "Anastasia")); Arg_scalar (Result_value (Int 35)) ] + ~inputs:[ Arg_scalar (Result_value (String "Anastasia")); Arg_scalar (Result_value (Int64 35L)) ] (Lazy.force db) "[:find ?e ?n ?l ?a ?s ?al :in $ ?n ?a :where [?e :name ?n] [?e :age ?a] [?e :last-name ?l] [?e :sex ?s] [?e :alias ?al]]")); bench config "qpred1" (fun () -> @@ -263,7 +263,7 @@ let main () = bench config "qpred2" (fun () -> consume_rows (q_string - ~inputs:[ Arg_scalar (Result_value (Int 50000)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 50000L)) ] (Lazy.force db) "[:find ?e ?s :in $ ?min-s :where [?e :salary ?s] [(> ?s ?min-s)]]")); bench config "q2pred" (fun () -> diff --git a/bench/memory_scenario.ml b/bench/memory_scenario.ml index 6884248..2f81760 100644 --- a/bench/memory_scenario.ml +++ b/bench/memory_scenario.ml @@ -75,12 +75,12 @@ let person size i = Entity { db_id = Some (Entity_id i) ; attrs = - [ "id", One_value (Int i) + [ "id", One_value (Int64 (Int64.of_int i)) ; "name", One_value (String names.((i - 1) mod Array.length names)) - ; "age", One_value (Int ((i * 37) mod 100)) - ; "salary", One_value (Int ((i * 7919) mod 100_000)) + ; "age", One_value (Int64 (Int64.of_int ((i * 37) mod 100))) + ; "salary", One_value (Int64 (Int64.of_int ((i * 7919) mod 100_000))) ; "status", One_value (String statuses.(i mod Array.length statuses)) - ; "score", One_value (Int ((i * 13) mod 10_000)) + ; "score", One_value (Int64 (Int64.of_int ((i * 13) mod 10_000))) ; "friend", One_value (Ref friend) ; "mentor", One_value (Ref mentor) ; ( "team" @@ -104,7 +104,7 @@ let update_entity size i = { db_id = Some (Entity_id entity_id) ; attrs = [ "status", One_value (String statuses.((i + 1) mod Array.length statuses)) - ; "score", One_value (Int ((i * 97) mod 10_000)) + ; "score", One_value (Int64 (Int64.of_int ((i * 97) mod 10_000))) ; "alias", Many_values [ String ("updated-" ^ string_of_int (i mod 128)) ] ] } @@ -152,8 +152,8 @@ let ref_attrs = [ "friend"; "mentor"; "team" ] let canonical_value attr = function - | Int value when List.mem attr ref_attrs -> "ref:" ^ string_of_int value - | Int value -> "int:" ^ string_of_int value + | Int64 value when List.mem attr ref_attrs -> "ref:" ^ Int64.to_string value + | Int64 value -> "int:" ^ Int64.to_string value | Ref entity_id -> "ref:" ^ string_of_int entity_id | String value -> "string:" ^ value | Bool value -> "bool:" ^ string_of_bool value diff --git a/bench/query_profile.ml b/bench/query_profile.ml index 9758d04..1532d13 100644 --- a/bench/query_profile.ml +++ b/bench/query_profile.ml @@ -82,8 +82,8 @@ let random_man rng i = ; "full-name", One_value (String (name ^ " " ^ last_name)) ; "alias", Many_values alias_values ; "sex", One_value (Keyword (if next_int rng 2 = 0 then "male" else "female")) - ; "age", One_value (Int (next_int rng 100)) - ; "salary", One_value (Int (next_int rng 100_000)) + ; "age", One_value (Int64 (Int64.of_int (next_int rng 100))) + ; "salary", One_value (Int64 (Int64.of_int (next_int rng 100_000))) ] } @@ -302,13 +302,13 @@ let () = (fun () -> q_len_inputs db - [ Arg_scalar (Result_value (Int 50000)) ] + [ Arg_scalar (Result_value (Int64 50000L)) ] "[:find ?e ?s :in $ ?min-s :where [?e :salary ?s] [(> ?s ?min-s)]]"); measure "qpred2-parsed" iterations (fun () -> - q db ~inputs:[ Arg_scalar (Result_value (Int 50000)) ] qpred2_query + q db ~inputs:[ Arg_scalar (Result_value (Int64 50000L)) ] qpred2_query |> rows_len); measure "q2pred" iterations (fun () -> q_len db "[:find ?e ?s :where [?e :name \"Ivan\"] [?e :salary ?s] [(> ?s 50000)]]"); measure "direct-q3-index-join" iterations (fun () -> direct_q3 db); diff --git a/examples/logseq_query_runner.ml b/examples/logseq_query_runner.ml index 8c375b9..8165f32 100644 --- a/examples/logseq_query_runner.ml +++ b/examples/logseq_query_runner.ml @@ -34,7 +34,7 @@ let edn_keyword value = ":" ^ value let rec edn_value = function | Nil -> "nil" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> Built_ins.print_query_value ~readably:true (String value) | Symbol value -> value @@ -42,7 +42,7 @@ let rec edn_value = function | Bool false -> "false" | Keyword value -> edn_keyword value | Uuid value -> "#uuid " ^ json_string value - | Instant value -> Int64.to_string value + | Instant value -> "#inst \"" ^ Util.string_of_instant_millis value ^ "\"" | Regex value -> "#\"" ^ String.escaped value ^ "\"" | Ref value -> string_of_int value | List values -> "(" ^ String.concat " " (List.map edn_value values) ^ ")" @@ -153,7 +153,7 @@ let schema_of_graph_edn_form = function let rec graph_value_of_form = function | QueryFormNil -> Nil | QueryFormBool value -> Bool value - | QueryFormInt value -> Int value + | QueryFormInt value -> Int64 value | QueryFormFloat value -> Float value | QueryFormString value -> String value | QueryFormKeyword value -> Keyword value @@ -170,7 +170,12 @@ let rec graph_value_of_form = function let datom_of_graph_edn_form = function | QueryFormVector [ QueryFormInt e; attr; value; QueryFormInt tx; QueryFormBool added ] | QueryFormList [ QueryFormInt e; attr; value; QueryFormInt tx; QueryFormBool added ] -> - datom ~e ~a:(Data_readers.attr_of_edn_key attr) ~v:(Util.normalize_value (graph_value_of_form value)) ~tx ~added () + datom ~e:(Util.int64_to_int_exn "graph datom entity" e) + ~a:(Data_readers.attr_of_edn_key attr) + ~v:(Util.normalize_value (graph_value_of_form value)) + ~tx:(Util.int64_to_int_exn "graph datom tx" tx) + ~added + () | _ -> invalid_arg "graph EDN :datoms entries must be [e attr value tx added]" let datoms_of_graph_edn_form = function diff --git a/examples/logseq_sqlite_storage.ml b/examples/logseq_sqlite_storage.ml index 87cdb1f..7eefc9d 100644 --- a/examples/logseq_sqlite_storage.ml +++ b/examples/logseq_sqlite_storage.ml @@ -240,7 +240,7 @@ let schema_to_transit schema = let rec value_to_transit = function | Nil -> Transit.Null - | Int value -> Transit.Int value + | Int64 value -> Transit.Int64 value | Float value -> Transit.Float value | String value -> Transit.String value | Symbol value -> Transit.Symbol value @@ -401,16 +401,12 @@ let rec value_of_transit = function | Transit.Null -> Nil | Transit.Bool value -> Bool value | Transit.String value -> String value - | Transit.Int value -> Int value - | Transit.Int64 value -> - if value >= Int64.of_int min_int && value <= Int64.of_int max_int then - Int (Int64.to_int value) - else - Instant value + | Transit.Int value -> Int64 (Int64.of_int value) + | Transit.Int64 value -> Int64 value | Transit.Float value -> Float value | Transit.Binary value -> String value | Transit.Big_decimal value -> Float (float_of_string value) - | Transit.Big_int value -> Transit.Int64 (Int64.of_string value) |> value_of_transit + | Transit.Big_int value -> Int64 (Int64.of_string value) | Transit.Date value -> Instant value | Transit.Uuid value -> Uuid value | Transit.Uri value -> String value @@ -899,18 +895,25 @@ let int_of_shallow_string text = | Some value -> value | None -> invalid_arg ("invalid Logseq integer value: " ^ text) +let int64_of_shallow_string text = + match Int64.of_string_opt text with + | Some value -> value + | None -> invalid_arg ("invalid Logseq integer value: " ^ text) + let rec logseq_value_of_shallow_json reader = function | `Null -> Nil | `Bool value -> Bool value - | `Int value -> Int value - | `Intlit value -> Int (int_of_shallow_string value) + | `Int value -> Int64 (Int64.of_int value) + | `Intlit value -> Int64 (int64_of_shallow_string value) | `Float value -> Float value | `Floatlit value -> Float (float_of_string value) | `String text -> let text = shallow_decode_string reader text in if starts_with "~:" text then Keyword (String.sub text 2 (String.length text - 2)) else if starts_with "~$" text then Symbol (String.sub text 2 (String.length text - 2)) - else if starts_with "~i" text then Int (int_of_shallow_string (String.sub text 2 (String.length text - 2))) + else if starts_with "~i" text then Int64 (int64_of_shallow_string (String.sub text 2 (String.length text - 2))) + else if starts_with "~n" text then Int64 (int64_of_shallow_string (String.sub text 2 (String.length text - 2))) + else if starts_with "~m" text then Instant (int64_of_shallow_string (String.sub text 2 (String.length text - 2))) else if starts_with "~u" text then Uuid (String.sub text 2 (String.length text - 2)) else if starts_with "~?" text then (match String.sub text 2 (String.length text - 2) with diff --git a/examples/sqlite_storage_example.ml b/examples/sqlite_storage_example.ml index 2a20442..401be70 100644 --- a/examples/sqlite_storage_example.ml +++ b/examples/sqlite_storage_example.ml @@ -67,7 +67,7 @@ let rec edn_of_pulled_value = function and edn_of_pulled_entity entity = let attrs = - (Keyword "db/id", Pulled_scalar (Int entity.pulled_id)) :: entity.pulled_attrs + (Keyword "db/id", Pulled_scalar (Int64 (Int64.of_int entity.pulled_id))) :: entity.pulled_attrs |> List.sort (fun (left, _) (right, _) -> compare left right) |> List.map (fun (key, value) -> Built_ins.print_query_value ~readably:true key ^ " " ^ edn_of_pulled_value value) diff --git a/impl/built_ins.ml b/impl/built_ins.ml index 1da2355..7ca71ee 100644 --- a/impl/built_ins.ml +++ b/impl/built_ins.ml @@ -16,15 +16,17 @@ let value_get collection key = | Map entries, key -> map_get_value entries key | Set values, key -> if List.exists (fun value -> compare_value value key = 0) values then Some key else None - | (List values | Vector values), Int index -> - if index >= 0 && index < List.length values then Some (List.nth values index) else None - | Tuple values, Int index -> - if index >= 0 && index < List.length values then - match List.nth values index with - | Some value -> Some value - | None -> Some Nil - else - None + | (List values | Vector values), Int64 index -> + (match Util.int64_to_int index with + | Some index when index >= 0 && index < List.length values -> Some (List.nth values index) + | _ -> None) + | Tuple values, Int64 index -> + (match Util.int64_to_int index with + | Some index when index >= 0 && index < List.length values -> + (match List.nth values index with + | Some value -> Some value + | None -> Some Nil) + | _ -> None) | _ -> None let value_count = function @@ -32,7 +34,7 @@ let value_count = function | List values | Vector values | Set values -> Some (List.length values) | Map entries -> Some (List.length entries) | Tuple values -> Some (List.length values) - | Nil | Int _ | Float _ | Bool _ | Keyword _ | Symbol _ | Uuid _ | Instant _ | Regex _ | Ref _ | TxRef | Ref_to _ -> None + | Nil | Int64 _ | Float _ | Bool _ | Keyword _ | Symbol _ | Uuid _ | Instant _ | Regex _ | Ref _ | TxRef | Ref_to _ -> None let value_has_count expected value = match value_count value with @@ -48,8 +50,9 @@ let matches_value_predicate predicate value = (* Ref values are entity ids — plain numbers upstream — so numeric predicates and arithmetic see them as integers *) match predicate, value with - | NumberValue, (Int _ | Float _ | Ref _ | Instant _) -> true - | IntegerValue, (Int _ | Ref _ | Instant _) -> true + (* Instant is a date, not a number — upstream number?/integer? reject it *) + | NumberValue, (Int64 _ | Float _ | Ref _) -> true + | IntegerValue, (Int64 _ | Ref _) -> true | StringValue, String _ -> true | BooleanValue, Bool _ -> true | KeywordValue, Keyword _ -> true @@ -57,22 +60,22 @@ let matches_value_predicate predicate value = let matches_numeric_predicate predicate value = match predicate, value with - | ZeroNumber, Int value -> value = 0 + | ZeroNumber, Int64 value -> value = 0L | ZeroNumber, Ref value -> value = 0 | ZeroNumber, Float value -> value = 0.0 | ZeroNumber, Instant value -> value = 0L - | PositiveNumber, Int value -> value > 0 + | PositiveNumber, Int64 value -> value > 0L | PositiveNumber, Ref value -> value > 0 | PositiveNumber, Float value -> value > 0.0 | PositiveNumber, Instant value -> value > 0L - | NegativeNumber, Int value -> value < 0 + | NegativeNumber, Int64 value -> value < 0L | NegativeNumber, Ref value -> value < 0 | NegativeNumber, Float value -> value < 0.0 | NegativeNumber, Instant value -> value < 0L - | EvenInteger, Int value -> value mod 2 = 0 + | EvenInteger, Int64 value -> Int64.rem value 2L = 0L | EvenInteger, Ref value -> value mod 2 = 0 | EvenInteger, Instant value -> Int64.rem value 2L = 0L - | OddInteger, Int value -> value mod 2 <> 0 + | OddInteger, Int64 value -> Int64.rem value 2L <> 0L | OddInteger, Ref value -> value mod 2 <> 0 | OddInteger, Instant value -> Int64.rem value 2L <> 0L | (EvenInteger | OddInteger), Float _ -> false @@ -101,82 +104,104 @@ let all_values_equal = function | first :: rest -> List.for_all (fun value -> compare_value first value = 0) rest let numeric_value = function - | Int value -> Some (`Int value) - | Ref value -> Some (`Int value) + | Int64 value -> Some (`Int64 value) + | Ref value -> Some (`Int64 (Int64.of_int value)) | Instant value -> Some (`Int64 value) | Float value -> Some (`Float value) | _ -> None -let numeric_result prefer_float value = - if prefer_float then - Float value - else - Int (int_of_float value) - let arithmetic_values values = let rec collect acc has_float = function | [] -> Some (List.rev acc, has_float) | value :: rest -> (match numeric_value value with | None -> None - | Some (`Int value) -> collect (float_of_int value :: acc) has_float rest - | Some (`Int64 value) -> collect (Int64.to_float value :: acc) true rest - | Some (`Float value) -> collect (value :: acc) true rest) + | Some (`Int64 value) -> collect (`Int64 value :: acc) has_float rest + | Some (`Float value) -> collect (`Float value :: acc) true rest) in collect [] false values +let float_of_numeric = function + | `Int64 value -> Int64.to_float value + | `Float value -> value + +let fold_int64 op initial items = + List.fold_left (fun acc item -> match item with `Int64 value -> op acc value | `Float _ -> assert false) initial items + +let fold_float op initial items = + List.fold_left (fun acc item -> op acc (float_of_numeric item)) initial items + let integer_pair = function - | [ Int left; Int right ] -> Some (left, right) + | [ `Int64 left; `Int64 right ] -> Some (left, right) | _ -> None let clojure_mod left right = - let remainder = left mod right in - if remainder = 0 || (remainder > 0) = (right > 0) then + let remainder = Int64.rem left right in + if remainder = 0L || (remainder > 0L) = (right > 0L) then remainder else - remainder + right + Int64.add remainder right let eval_arithmetic op values = match op, values, arithmetic_values values with - | QuotientNumbers, _, _ -> + | QuotientNumbers, _, Some (items, _) -> let left, right = - match integer_pair values with + match integer_pair items with | Some pair -> pair | None -> invalid_arg "integer arithmetic expects two integer values" in - Some (Int (left / right)) - | RemainderNumbers, _, _ -> + Some (Int64 (Int64.div left right)) + | RemainderNumbers, _, Some (items, _) -> let left, right = - match integer_pair values with + match integer_pair items with | Some pair -> pair | None -> invalid_arg "integer arithmetic expects two integer values" in - Some (Int (left mod right)) - | ModuloNumbers, _, _ -> + Some (Int64 (Int64.rem left right)) + | ModuloNumbers, _, Some (items, _) -> let left, right = - match integer_pair values with + match integer_pair items with | Some pair -> pair | None -> invalid_arg "integer arithmetic expects two integer values" in - Some (Int (clojure_mod left right)) + Some (Int64 (clojure_mod left right)) + | (QuotientNumbers | RemainderNumbers | ModuloNumbers), _, None -> + invalid_arg "integer arithmetic expects two integer values" | _, _, None -> invalid_arg "arithmetic expects numeric values" - | IncrementNumber, _, Some ([ value ], has_float) -> Some (numeric_result has_float (value +. 1.0)) - | DecrementNumber, _, Some ([ value ], has_float) -> Some (numeric_result has_float (value -. 1.0)) + | IncrementNumber, _, Some ([ `Int64 value ], _) -> Some (Int64 (Int64.add value 1L)) + | IncrementNumber, _, Some ([ `Float value ], _) -> Some (Float (value +. 1.0)) + | DecrementNumber, _, Some ([ `Int64 value ], _) -> Some (Int64 (Int64.sub value 1L)) + | DecrementNumber, _, Some ([ `Float value ], _) -> Some (Float (value -. 1.0)) | (IncrementNumber | DecrementNumber), _, _ -> invalid_arg "unary arithmetic expects one value" - | AddNumbers, _, Some (values, has_float) -> - Some (numeric_result has_float (List.fold_left ( +. ) 0.0 values)) + | AddNumbers, _, Some (items, has_float) -> + if has_float then + Some (Float (fold_float ( +. ) 0.0 items)) + else + Some (Int64 (fold_int64 Int64.add 0L items)) | SubtractNumbers, _, Some ([], _) -> invalid_arg "subtraction expects at least one value" - | SubtractNumbers, _, Some ([ value ], has_float) -> Some (numeric_result has_float (~-. value)) + | SubtractNumbers, _, Some ([ `Int64 value ], _) -> Some (Int64 (Int64.neg value)) + | SubtractNumbers, _, Some ([ `Float value ], _) -> Some (Float (~-. value)) | SubtractNumbers, _, Some (first :: rest, has_float) -> - Some (numeric_result has_float (List.fold_left ( -. ) first rest)) - | MultiplyNumbers, _, Some (values, has_float) -> - Some (numeric_result has_float (List.fold_left ( *. ) 1.0 values)) + if has_float then + Some (Float (List.fold_left (fun acc item -> acc -. float_of_numeric item) (float_of_numeric first) rest)) + else + (match first with + | `Int64 first -> Some (Int64 (fold_int64 Int64.sub first rest)) + | `Float _ -> assert false) + | MultiplyNumbers, _, Some (items, has_float) -> + if has_float then + Some (Float (fold_float ( *. ) 1.0 items)) + else + Some (Int64 (fold_int64 Int64.mul 1L items)) | DivideNumbers, _, Some ([], _) -> invalid_arg "division expects at least one value" - | DivideNumbers, _, Some ([ value ], _) -> Some (Float (1.0 /. value)) + | DivideNumbers, _, Some ([ item ], _) -> Some (Float (1.0 /. float_of_numeric item)) | DivideNumbers, _, Some (first :: rest, has_float) -> - let result = List.fold_left ( /. ) first rest in + let result = List.fold_left (fun acc item -> acc /. float_of_numeric item) (float_of_numeric first) rest in let integral = Float.is_integer result in - Some (numeric_result (has_float || not integral) result) + if has_float || not integral then + Some (Float result) + else + Some (Int64 (Int64.of_float result)) let normalized_comparison comparison = if comparison < 0 then -1 else if comparison > 0 then 1 else 0 @@ -291,7 +316,7 @@ let string_of_query_value = function | String value -> value | Symbol value -> value | Nil -> "" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | Bool true -> "true" | Bool false -> "false" @@ -321,13 +346,14 @@ let rec print_query_value ~readably = function | String value -> if readably then escaped_string_literal value else value | Symbol value -> value | Nil -> "nil" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | Bool true -> "true" | Bool false -> "false" | Keyword value -> ":" ^ value | Uuid value -> value - | Instant value -> Int64.to_string value + | Instant value -> + if readably then "#inst \"" ^ Util.string_of_instant_millis value ^ "\"" else Int64.to_string value | Regex value -> "#\"" ^ value ^ "\"" | Ref entity_id -> string_of_int entity_id | List values -> "(" ^ print_query_values ~readably values ^ ")" @@ -473,7 +499,7 @@ let query_result_value = function | Result_db _ | Result_pull _ -> None let float_of_result = function - | Result_value (Int value) -> float_of_int value + | Result_value (Int64 value) -> Int64.to_float value | Result_value (Float value) -> value | Result_value (Instant value) -> Int64.to_float value | _ -> invalid_arg "aggregate expects numeric values" @@ -483,16 +509,16 @@ let numeric_values values = List.map float_of_result values let sum_result values = let rec sum int_total float_total has_float = function | [] -> - if has_float then Result_value (Float float_total) else Result_value (Int int_total) - | Result_value (Int value) :: rest -> - sum (int_total + value) (float_total +. float_of_int value) has_float rest + if has_float then Result_value (Float float_total) else Result_value (Int64 int_total) + | Result_value (Int64 value) :: rest -> + sum (Int64.add int_total value) (float_total +. Int64.to_float value) has_float rest | Result_value (Float value) :: rest -> sum int_total (float_total +. value) true rest | Result_value (Instant value) :: rest -> sum int_total (float_total +. Int64.to_float value) true rest | _ -> invalid_arg "aggregate expects numeric values" in - sum 0 0.0 false values + sum 0L 0.0 false values let average values = let values = numeric_values values in @@ -581,8 +607,8 @@ let sample_results amount values = let aggregate_result aggregate values = match aggregate, values with - | Count, values -> Result_value (Int (List.length values)) - | CountDistinct, values -> Result_value (Int (List.length (List.sort_uniq compare values))) + | Count, values -> Result_value (Int64 (Int64.of_int (List.length values))) + | CountDistinct, values -> Result_value (Int64 (Int64.of_int (List.length (List.sort_uniq compare values)))) | Distinct, values -> values |> List.filter_map query_result_value @@ -672,7 +698,7 @@ let values_equal left right = compare_value left right = 0 let type_keyword_of_value = function - | Int _ -> "type/int" + | Int64 _ -> "type/int" | Float _ -> "type/float" | String _ -> "type/string" | Symbol _ -> "type/symbol" @@ -697,18 +723,22 @@ let value_contains collection key = List.exists (fun (entry_key, _) -> compare_value entry_key key = 0) entries | Set values, key -> List.exists (fun value -> compare_value value key = 0) values - | (List values | Vector values), Int index -> - index >= 0 && index < List.length values - | Tuple values, Int index -> - index >= 0 && index < List.length values + | (List values | Vector values), Int64 index -> + (match Util.int64_to_int index with + | Some index -> index >= 0 && index < List.length values + | None -> false) + | Tuple values, Int64 index -> + (match Util.int64_to_int index with + | Some index -> index >= 0 && index < List.length values + | None -> false) | _ -> false let range_values start_value end_value step = - if step = 0 then invalid_arg "range step cannot be zero"; + if step = 0L then invalid_arg "range step cannot be zero"; let rec collect value acc = - if (step > 0 && value >= end_value) || (step < 0 && value <= end_value) then + if (step > 0L && value >= end_value) || (step < 0L && value <= end_value) then List.rev acc else - collect (value + step) (value :: acc) + collect (Int64.add value step) (value :: acc) in collect start_value [] diff --git a/impl/built_ins.mli b/impl/built_ins.mli index 9a8e0ac..87203fc 100644 --- a/impl/built_ins.mli +++ b/impl/built_ins.mli @@ -56,4 +56,4 @@ val split_at : int -> 'a list -> 'a list * 'a list val values_equal : value -> value -> bool val type_keyword_of_value : value -> string val value_contains : value -> value -> bool -val range_values : int -> int -> int -> int list +val range_values : int64 -> int64 -> int64 -> int64 list diff --git a/impl/data_readers.ml b/impl/data_readers.ml index afb1aea..e26ac55 100644 --- a/impl/data_readers.ml +++ b/impl/data_readers.ml @@ -44,8 +44,11 @@ let keyword_name_of_form = function | _ -> invalid_arg "expected EDN keyword or symbol" let rec entity_ref_of_edn_form context = function - | QueryFormInt entity_id when entity_id < 0 -> Temp_id (string_of_int entity_id) - | QueryFormInt entity_id -> Entity_id entity_id + | QueryFormInt entity_id when entity_id < 0L -> Temp_id (Int64.to_string entity_id) + | QueryFormInt entity_id -> + (match Util.int64_to_int entity_id with + | Some entity_id -> Entity_id entity_id + | None -> invalid_arg ("entity id out of int range: " ^ Int64.to_string entity_id)) | QueryFormString tempid -> Temp_id tempid | QueryFormKeyword "db/current-tx" | QueryFormSymbol "db/current-tx" -> CurrentTx @@ -139,7 +142,7 @@ and tx_entity_of_edn_map context entries = { db_id; attrs = List.rev attrs } let explicit_tx_of_edn_form = function - | QueryFormInt tx -> tx + | QueryFormInt tx -> Util.int64_to_int_exn "explicit transaction tx" tx | _ -> invalid_arg "explicit transaction tx must be an integer" let entity_id_of_explicit_datom_edn_form context form = @@ -160,7 +163,7 @@ let raw_datom_of_edn_forms context ?(added = true) entity_ref attr value tx = let raw_datom_of_tagged_edn_form context = function | QueryFormVector [ entity_ref; attr; value ] | QueryFormList [ entity_ref; attr; value ] -> - raw_datom_of_edn_forms context entity_ref attr value (QueryFormInt context.tx0) + raw_datom_of_edn_forms context entity_ref attr value (QueryFormInt (Int64.of_int context.tx0)) | QueryFormVector [ entity_ref; attr; value; tx ] | QueryFormList [ entity_ref; attr; value; tx ] -> raw_datom_of_edn_forms context entity_ref attr value tx diff --git a/impl/datascript.ml b/impl/datascript.ml index 8981319..87bc649 100644 --- a/impl/datascript.ml +++ b/impl/datascript.ml @@ -185,13 +185,13 @@ let entid_in_datoms = Transact_datoms_impl.entid_in_datoms let rec edn_string_of_value = function | Nil -> "nil" | Bool value -> if value then "true" else "false" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> "\"" ^ String.escaped value ^ "\"" | Keyword value -> ":" ^ value | Symbol value -> value | Uuid value -> "#uuid \"" ^ value ^ "\"" - | Instant millis -> Int64.to_string millis + | Instant millis -> "#inst \"" ^ Util.string_of_instant_millis millis ^ "\"" | Regex value -> "#\"" ^ String.escaped value ^ "\"" | Ref entity_id -> string_of_int entity_id | TxRef -> ":db/current-tx" @@ -290,7 +290,8 @@ let rec coerce_tuple_lookup_value_db db attr value = let coerce_component source_attr value = match value with | Nil -> None - | Int entity_id when is_ref_attr db source_attr -> Some (Ref (validate_entity_id entity_id)) + | Int64 entity_id when is_ref_attr db source_attr -> + Some (Ref (validate_entity_id (Util.int64_to_int_exn "tuple component entity id" entity_id))) | (List [ lookup_attr; lookup_value ] | Vector [ lookup_attr; lookup_value ]) when is_ref_attr db source_attr -> (match Option.bind (lookup_attr_name lookup_attr) (fun attr -> entid_db db attr lookup_value) with | Some entity_id -> Some (Ref entity_id) @@ -307,7 +308,8 @@ let rec coerce_tuple_lookup_value_db db attr value = let coerce_component source_attr = function | None -> None | Some Nil -> None - | Some (Int entity_id) when is_ref_attr db source_attr -> Some (Ref (validate_entity_id entity_id)) + | Some (Int64 entity_id) when is_ref_attr db source_attr -> + Some (Ref (validate_entity_id (Util.int64_to_int_exn "tuple component entity id" entity_id))) | Some ((List [ lookup_attr; lookup_value ] | Vector [ lookup_attr; lookup_value ]) as lookup_ref) when is_ref_attr db source_attr -> (match Option.bind (lookup_attr_name lookup_attr) (fun attr -> entid_db db attr lookup_value) with | Some entity_id -> Some (Ref entity_id) @@ -411,7 +413,7 @@ let validate_datom_value db d = | TupleType, Tuple _ -> true | StringType, String _ -> true | KeywordType, Keyword _ -> true - | NumberType, (Int _ | Float _) -> true + | NumberType, (Int64 _ | Float _) -> true | UuidType, Uuid _ -> true | InstantType, Instant _ -> true | _ -> false @@ -451,7 +453,7 @@ let validate_datom_value db d = | _ -> invalid_arg ("keyword attribute requires keyword value: " ^ d.a)) | Some { value_type = Some NumberType; _ } -> (match d.v with - | Int _ | Float _ -> () + | Int64 _ | Float _ -> () | _ -> invalid_arg ("number attribute requires numeric value: " ^ d.a)) | Some { value_type = Some UuidType; _ } -> (match d.v with @@ -1136,7 +1138,10 @@ let query_entity_id_term db = function (match entid db ident_attr (Keyword ident) with | Some entity_id -> Resolved_eid entity_id | None -> Unresolved_eid) - | QValue (Int entity_id) -> Resolved_eid entity_id + | QValue (Int64 entity_id) -> + (match Util.int64_to_int entity_id with + | Some entity_id -> Resolved_eid entity_id + | None -> Unresolved_eid) | QValue value -> (match Query.query_result_entity_id (query_result_context db) (Result_value value) with | Some entity_id -> Resolved_eid entity_id @@ -1158,7 +1163,7 @@ let query_value_term = function | _ -> None let query_tx_term = function - | Some (QValue (Int tx)) -> Some tx + | Some (QValue (Int64 tx)) -> Util.int64_to_int tx | _ -> None let query_attr_uses_avet db attr = @@ -1166,7 +1171,7 @@ let query_attr_uses_avet db attr = let query_value_uses_avet = function | Nil | List _ | Vector _ | Map _ | Set _ | Tuple _ | TxRef -> false - | Int _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | Ref _ | Ref_to _ -> true + | Int64 _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | Ref _ | Ref_to _ -> true let resolve_query_value_for_attr db attr value = match ref_attr_for_value_resolution db attr, entity_ref_of_ref_attr_value value with @@ -1177,11 +1182,14 @@ let resolve_query_value_for_attr db attr value = let values_compare_equal_fast left right = match left, right with | Nil, Nil -> true - | Int left, Int right - | Ref left, Ref right - | Int left, Ref right - | Ref left, Int right -> + | Int64 left, Int64 right -> + left = right + | Ref left, Ref right -> left = right + | Int64 left, Ref right -> + left = Int64.of_int right + | Ref left, Int64 right -> + Int64.of_int left = right | String left, String right | Symbol left, Symbol right | Keyword left, Keyword right @@ -2102,7 +2110,7 @@ module Query = struct attrs |> List.filter_map (fun attr -> if attr = "db/id" then - Some (Keyword "db/id", Pulled_scalar (Int entity_id)) + Some (Keyword "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id))) else let values = Option.bind (List.assoc_opt attr attr_tables) (fun table -> Hashtbl.find_opt table entity_id) @@ -2136,7 +2144,7 @@ module Query = struct attrs |> List.filter_map (fun attr -> if attr = "db/id" then - Some (Keyword "db/id", Pulled_scalar (Int entity_id)) + Some (Keyword "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id))) else let values = Option.value (List.assoc_opt attr tables) ~default:[] in Option.map (fun value -> Keyword attr, value) (pulled_value attr values)) @@ -2172,7 +2180,7 @@ module Query = struct in let ref_id_of_value attr = function | Ref entity_id -> Some entity_id - | Int entity_id when is_ref_attr_cached attr -> Some entity_id + | Int64 entity_id when is_ref_attr_cached attr -> Util.int64_to_int entity_id | _ -> None in let batch_nested_pull_values selector entity_ids = @@ -2252,7 +2260,7 @@ module Query = struct attrs |> List.filter_map (fun attr -> if attr = "db/id" then - Some (Keyword "db/id", Pulled_scalar (Int entity_id)) + Some (Keyword "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id))) else Option.map (fun value -> Keyword attr, value) @@ -2277,7 +2285,7 @@ module Query = struct let pulled_attrs = roots |> List.filter_map (function - | `Attr "db/id" -> Some (Keyword "db/id", Pulled_scalar (Int entity_id)) + | `Attr "db/id" -> Some (Keyword "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id))) | `Attr attr -> Option.map (fun value -> Keyword attr, value) (pulled_value attr (root_values attr entity_id)) | `Ref (attr, nested) -> @@ -2665,7 +2673,7 @@ module Query = struct attrs |> List.filter_map (fun attr -> if attr = "db/id" then - Some (Keyword "db/id", Pulled_scalar (Int entity_id)) + Some (Keyword "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id))) else Option.bind (List.assoc_opt attr attr_tables) (fun table -> Hashtbl.find_opt table entity_id) |> Option.map (fun value -> Keyword attr, Pulled_scalar value)) diff --git a/impl/datascript.mli b/impl/datascript.mli index 66126f1..96cabc8 100644 --- a/impl/datascript.mli +++ b/impl/datascript.mli @@ -57,7 +57,7 @@ module Built_ins : sig val values_equal : value -> value -> bool val type_keyword_of_value : value -> string val value_contains : value -> value -> bool - val range_values : int -> int -> int -> int list + val range_values : int64 -> int64 -> int64 -> int64 list end module Data_readers : sig @@ -152,8 +152,8 @@ module Db : sig val hash : db -> int val hash_cache_size : unit -> int val diff : db -> db -> datom list * datom list * datom list - val squuid : ?msec:int -> unit -> value - val squuid_time_millis : value -> int + val squuid : ?msec:int64 -> unit -> value + val squuid_time_millis : value -> int64 end module Entity : sig @@ -262,6 +262,10 @@ module Storage : sig end module Util : sig + val int64_to_int : int64 -> int option + val int64_to_int_exn : string -> int64 -> int + val civil_from_days : int64 -> int * int * int + val string_of_instant_millis : int64 -> string val list_equal_by : ('a -> 'a -> bool) -> 'a list -> 'a list -> bool val entity_ref_equal : entity_ref -> entity_ref -> bool val value_equal : value -> value -> bool @@ -419,8 +423,8 @@ val collect_garbage : storage -> unit val db_hash : db -> int val db_hash_cache_size : unit -> int val diff : db -> db -> datom list * datom list * datom list -val squuid : ?msec:int -> unit -> value -val squuid_time_millis : value -> int +val squuid : ?msec:int64 -> unit -> value +val squuid_time_millis : value -> int64 val create_conn : ?schema:schema -> ?storage:storage -> unit -> conn val conn_from_db : db -> conn val conn_from_datoms : ?schema:schema -> ?storage:storage -> datom list -> conn diff --git a/impl/db.ml b/impl/db.ml index cf8a2aa..ce46057 100644 --- a/impl/db.ml +++ b/impl/db.ml @@ -52,7 +52,7 @@ let rec max_eid_in_value max_eid = function | Some value -> max_eid_in_value max_eid value) max_eid values - | Nil | Int _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | TxRef | Ref_to _ -> max_eid + | Nil | Int64 _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | TxRef | Ref_to _ -> max_eid let value_equal = Util.value_equal @@ -493,11 +493,14 @@ let matches maybe expected = Option.fold ~none:true ~some:(fun actual -> actual let values_compare_equal context actual expected = match actual, expected with | Nil, Nil -> true - | Int actual, Int expected - | Ref actual, Ref expected - | Int actual, Ref expected - | Ref actual, Int expected -> + | Int64 actual, Int64 expected -> actual = expected + | Ref actual, Ref expected -> + actual = expected + | Int64 actual, Ref expected -> + actual = Int64.of_int expected + | Ref actual, Int64 expected -> + Int64.of_int actual = expected | String actual, String expected | Symbol actual, Symbol expected | Keyword actual, Keyword expected @@ -1031,7 +1034,7 @@ let squuid ?msec () = incr squuid_counter; let seconds = match msec with - | Some msec -> Float.of_int msec /. 1000.0 + | Some msec -> Int64.to_float msec /. 1000.0 | None -> Platform.now_seconds () in let seconds_hex = hex8_of_seconds seconds in @@ -1046,5 +1049,5 @@ let squuid ?msec () = let squuid_time_millis = function | Uuid uuid -> if String.length uuid < 8 then invalid_arg "invalid squuid"; - int_of_string ("0x" ^ String.sub uuid 0 8) * 1000 + Int64.mul (Int64.of_string ("0x" ^ String.sub uuid 0 8)) 1000L | _ -> invalid_arg "squuid_time_millis expects a uuid value" diff --git a/impl/db.mli b/impl/db.mli index fd8d812..a126513 100644 --- a/impl/db.mli +++ b/impl/db.mli @@ -67,5 +67,5 @@ val index_range : index_context -> db -> attr -> ?start:value -> ?stop:value -> val hash : db -> int val hash_cache_size : unit -> int val diff : db -> db -> datom list * datom list * datom list -val squuid : ?msec:int -> unit -> value -val squuid_time_millis : value -> int +val squuid : ?msec:int64 -> unit -> value +val squuid_time_millis : value -> int64 diff --git a/impl/entity.ml b/impl/entity.ml index 5eed076..d96d94b 100644 --- a/impl/entity.ml +++ b/impl/entity.ml @@ -31,7 +31,10 @@ let entity_visible_attr_values context db attr values = yet ref-typed) is read back as an entity id. *) values |> List.map (function - | Int entity_id -> Ref entity_id + | Int64 entity_id -> + (match Util.int64_to_int entity_id with + | Some entity_id -> Ref entity_id + | None -> invalid_arg ("entity id out of range: " ^ Int64.to_string entity_id)) | v -> v) |> List.filter (function | Ref entity_id -> entity_has_forward_attrs context db entity_id @@ -118,7 +121,7 @@ let entity context db entity_ref = None let entity_attr_raw (entity : entity) = function - | "db/id" -> Some (One_value (Int entity.id)) + | "db/id" -> Some (One_value (Int64 (Int64.of_int entity.id))) | attr -> entity.lookup_attr attr let rec materialized_tx_entity context db visited entity_id = diff --git a/impl/parser.ml b/impl/parser.ml index 8737abc..280f4a6 100644 --- a/impl/parser.ml +++ b/impl/parser.ml @@ -112,7 +112,7 @@ let read_edn input = | _ when String.length token > 0 && token.[0] = ':' -> QueryFormKeyword (String.sub token 1 (String.length token - 1)) | _ -> - (match int_of_string_opt token with + (match Int64.of_string_opt token with | Some value -> QueryFormInt value | None -> if String.contains token '.' || String.contains token 'e' || String.contains token 'E' then @@ -302,7 +302,7 @@ let read_edn input = let rec query_value_of_form = function | QueryFormNil -> Nil | QueryFormBool value -> Bool value - | QueryFormInt value -> Int value + | QueryFormInt value -> Int64 value | QueryFormFloat value -> Float value | QueryFormString value -> String value | QueryFormKeyword value -> Keyword value @@ -326,7 +326,7 @@ let rec query_value_of_form = function let rec query_form_of_value = function | Nil -> QueryFormNil | Bool value -> QueryFormBool value - | Int value -> QueryFormInt value + | Int64 value -> QueryFormInt value | Float value -> QueryFormFloat value | String value -> QueryFormString value | Keyword value -> QueryFormKeyword value @@ -339,9 +339,9 @@ let rec query_form_of_value = function | Map entries -> QueryFormMap (List.map (fun (key, value) -> query_form_of_value key, query_form_of_value value) entries) | Uuid value -> QueryFormTagged ("uuid", QueryFormString value) - | Instant value -> QueryFormInt (Int64.to_int value) + | Instant value -> QueryFormInt value | Regex value -> QueryFormTagged ("regex", QueryFormString value) - | Ref entity_id -> QueryFormInt entity_id + | Ref entity_id -> QueryFormInt (Int64.of_int entity_id) | TxRef | Ref_to _ -> invalid_arg "cannot convert value to query form" @@ -689,10 +689,13 @@ let parse_pattern_term | QueryFormSymbol symbol when source_position && is_query_source_symbol symbol -> QSource (query_source_name symbol) | QueryFormSymbol symbol -> QValue (Symbol symbol) - | QueryFormInt entity_id when entity_position -> QEntity entity_id + | QueryFormInt entity_id when entity_position -> + (match Util.int64_to_int entity_id with + | Some entity_id -> QEntity entity_id + | None -> QValue (Int64 entity_id)) | QueryFormKeyword attr when attr_position -> QAttr attr | QueryFormKeyword value -> QValue (Keyword value) - | QueryFormInt value -> QValue (Int value) + | QueryFormInt value -> QValue (Int64 value) | QueryFormFloat value -> QValue (Float value) | QueryFormString value -> QValue (String value) | QueryFormBool value -> QValue (Bool value) @@ -1142,7 +1145,7 @@ let parse_find_form context ?(defer_pull_patterns = false) ?default_pull_db ?pul | [] -> invalid_arg "aggregate custom aggregate requires at least one argument" | args -> Find_aggregate (CustomVar (query_symbol_name aggregate_var), parse_find_args args)) | Some [ QueryFormSymbol aggregate; QueryFormInt amount; QueryFormSymbol var ] -> - (match amount_aggregate_of_symbol aggregate amount with + (match amount_aggregate_of_symbol aggregate (Util.int64_to_int_exn "aggregate amount" amount) with | Some aggregate -> Find_aggregate (aggregate, [ QVar (query_symbol_name var) ]) | None -> invalid_arg "find elements must be variable symbols") | Some [ QueryFormSymbol aggregate; QueryFormSymbol amount_var; QueryFormSymbol var ] diff --git a/impl/pull_api.ml b/impl/pull_api.ml index 3525ead..1da02f4 100644 --- a/impl/pull_api.ml +++ b/impl/pull_api.ml @@ -27,11 +27,12 @@ let compare_pull_key context left right = | _ -> context.compare_value left right let pulled_id_stub entity_id = - Pulled_entity { pulled_id = entity_id; pulled_attrs = [ pull_key_of_attr "db/id", Pulled_scalar (Int entity_id) ] } + Pulled_entity { pulled_id = entity_id; pulled_attrs = [ pull_key_of_attr "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id)) ] } let ref_entity_id_of_value context db attr = function | Ref entity_id -> Some entity_id - | Int entity_id when context.is_ref_attr db attr -> context.entity_id_of_ref db (Entity_id entity_id) + | Int64 entity_id when context.is_ref_attr db attr -> + Option.bind (Util.int64_to_int entity_id) (fun entity_id -> context.entity_id_of_ref db (Entity_id entity_id)) | _ -> None let shallow_pulled_value context db attr value = @@ -248,11 +249,11 @@ and pull_entity_by_id_visited ?visitor ~root_id ~root_reexpanded context db visi | attrs -> Some { pulled_id = entity.id; pulled_attrs = attrs }) and pull_selector_attrs ?visitor ~root_id ~root_reexpanded context db visited context_selector entity = function - | Pull_id -> [ pull_key_of_attr "db/id", Pulled_scalar (Int entity.id) ] + | Pull_id -> [ pull_key_of_attr "db/id", Pulled_scalar (Int64 (Int64.of_int entity.id)) ] | Pull_wildcard -> visit_pull visitor (PullVisitWildcard entity.id); let shadowed_attrs = wildcard_shadowed_attrs context context_selector in - (pull_key_of_attr "db/id", Pulled_scalar (Int entity.id)) + (pull_key_of_attr "db/id", Pulled_scalar (Int64 (Int64.of_int entity.id))) :: (context.entity_attrs entity |> List.filter (fun (attr, _) -> (not (context.is_reverse_ref attr)) && not (List.mem attr shadowed_attrs)) @@ -682,7 +683,7 @@ let pull_wildcard_entity ?visitor context db entity_id attrs = } in visit_pull visitor (PullVisitWildcard entity_id); - (pull_key_of_attr "db/id", Pulled_scalar (Int entity_id)) + (pull_key_of_attr "db/id", Pulled_scalar (Int64 (Int64.of_int entity_id))) :: (attrs |> List.filter (fun (attr, _) -> not (context.is_reverse_ref attr)) |> List.map (fun (attr, value) -> diff --git a/impl/pull_parser.ml b/impl/pull_parser.ml index fd5e5f8..97ad077 100644 --- a/impl/pull_parser.ml +++ b/impl/pull_parser.ml @@ -86,15 +86,15 @@ let with_pull_limit_form context db selector limit_form = validate_pull_limit_target context db selector; match limit_form with | QueryFormInt limit -> - if limit <= 0 then invalid_arg "pull :limit must be positive"; - with_pull_limit selector limit + if limit <= 0L then invalid_arg "pull :limit must be positive"; + with_pull_limit selector (Util.int64_to_int_exn "pull :limit" limit) | QueryFormNil -> with_pull_unlimited selector | _ -> invalid_arg "pull :limit requires an integer or nil" let pull_string_of_value = function | String value | Symbol value -> value | Nil -> "" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | Bool true -> "true" | Bool false -> "false" @@ -148,7 +148,7 @@ let rec with_pull_xform selector f = let pull_alias_key_of_form = function | QueryFormKeyword alias -> Keyword alias | QueryFormString alias -> String alias - | QueryFormInt alias -> Int alias + | QueryFormInt alias -> Int64 alias | QueryFormNil -> Nil | _ -> invalid_arg "pull :as requires keyword, string, integer, or nil" @@ -263,8 +263,8 @@ and parse_pull_map_spec context db attr_spec pattern = | QueryFormSymbol "..." | QueryFormString "..." -> with_pull_recursive_ref context db selector None | QueryFormInt depth -> - if depth <= 0 then invalid_arg "recursive pull depth must be positive"; - with_pull_recursive_ref context db selector (Some depth) + if depth <= 0L then invalid_arg "recursive pull depth must be positive"; + with_pull_recursive_ref context db selector (Some (Util.int64_to_int_exn "recursive pull depth" depth)) | _ -> with_pull_ref_pattern context db selector (parse_pattern context db pattern) and parse_pattern context db = function diff --git a/impl/query.ml b/impl/query.ml index 8a8ce59..18205ec 100644 --- a/impl/query.ml +++ b/impl/query.ml @@ -275,8 +275,9 @@ let grouping_vars_of_find find = let aggregate_amount_value var binding = match List.assoc_opt var binding with - | Some (Result_value (Int amount)) when amount >= 0 -> amount - | Some (Result_value (Int _)) -> invalid_arg "aggregate amount must be non-negative" + | Some (Result_value (Int64 amount)) when amount >= 0L -> + Util.int64_to_int_exn "aggregate amount" amount + | Some (Result_value (Int64 _)) -> invalid_arg "aggregate amount must be non-negative" | Some _ -> invalid_arg "aggregate amount must be an integer" | None -> invalid_arg ("aggregate amount variable is unbound: " ^ var) @@ -414,7 +415,8 @@ let result_of_ref = function let entity_id_of_resolved_query_result ~validate_entity_id = function | Some (Result_entity entity_id) -> Some entity_id - | Some (Result_value (Int entity_id)) -> Some (validate_entity_id entity_id) + | Some (Result_value (Int64 entity_id)) -> + Option.map validate_entity_id (Util.int64_to_int entity_id) | Some (Result_value (Ref entity_id)) -> Some entity_id | _ -> None @@ -467,7 +469,7 @@ let query_results_equivalent context left right = let left_resolved = resolved_query_result context left in let right_resolved = resolved_query_result context right in let is_entity_candidate = function - | Some (Result_entity _) | Some (Result_value (Int _ | Ref _)) -> true + | Some (Result_entity _) | Some (Result_value (Int64 _ | Ref _)) -> true | _ -> false in if is_entity_candidate left_resolved || is_entity_candidate right_resolved then diff --git a/impl/query_eval.ml b/impl/query_eval.ml index 9b7c0bf..a1740a5 100644 --- a/impl/query_eval.ml +++ b/impl/query_eval.ml @@ -146,7 +146,7 @@ let eval_count_value_clause context db bindings term output_var = (match value_count value with | None -> [] | Some count -> - (match bind_var (context.result_resolution_context db) output_var (Result_value (Int count)) bindings with + (match bind_var (context.result_resolution_context db) output_var (Result_value (Int64 (Int64.of_int count))) bindings with | Some bindings -> [ bindings ] | None -> [])) | Some (Result_entity _) | Some (Result_attr _) | Some (Result_db _) | Some (Result_pull _) | None -> [] @@ -222,7 +222,7 @@ let normalized_comparison = Built_ins.normalized_comparison let eval_compare_value_clause context db bindings left_term right_term output_var = match collect_query_values context db bindings [ left_term; right_term ] with | Some [ left; right ] -> - (match bind_var (context.result_resolution_context db) output_var (Result_value (Int (normalized_comparison (context.compare_value left right)))) bindings with + (match bind_var (context.result_resolution_context db) output_var (Result_value (Int64 (Int64.of_int (normalized_comparison (context.compare_value left right))))) bindings with | Some bindings -> [ bindings ] | None -> []) | Some _ | None -> [] @@ -316,11 +316,12 @@ let eval_random_value_clause context db bindings output_var = let eval_random_int_value_clause context db bindings bound_term output_var = match eval_query_term (context.match_context db) bindings bound_term with - | Some (Result_value (Int bound)) when bound > 0 -> - (match bind_var (context.result_resolution_context db) output_var (Result_value (Int (Random.int bound))) bindings with + | Some (Result_value (Int64 bound)) when bound > 0L -> + let bound = Util.int64_to_int_exn "rand-int bound" bound in + (match bind_var (context.result_resolution_context db) output_var (Result_value (Int64 (Int64.of_int (Random.int bound)))) bindings with | Some bindings -> [ bindings ] | None -> []) - | Some (Result_value (Int _)) -> invalid_arg "rand-int bound must be positive" + | Some (Result_value (Int64 _)) -> invalid_arg "rand-int bound must be positive" | Some _ | None -> [] let split_at = Built_ins.split_at @@ -449,13 +450,13 @@ let eval_string_index_clause context db bindings value_term needle_term output_v (match index_of value needle with | None -> [] | Some index -> - (match bind_var (context.result_resolution_context db) output_var (Result_value (Int index)) bindings with + (match bind_var (context.result_resolution_context db) output_var (Result_value (Int64 (Int64.of_int index))) bindings with | Some bindings -> [ bindings ] | None -> [])) | Some _ | None -> [] let query_result_int = function - | Result_value (Int value) -> Some value + | Result_value (Int64 value) -> Util.int64_to_int value | Result_value _ | Result_entity _ | Result_attr _ | Result_db _ | Result_pull _ -> None let eval_string_substring_clause context db bindings value_term start_term end_term output_var = @@ -637,14 +638,16 @@ let eval_string_split_clause context db bindings value_term separator_term outpu let eval_string_split_limit_clause context db bindings value_term separator_term limit_term output_var = match collect_query_terms (context.match_context db) bindings [ value_term; separator_term; limit_term ] with - | Some [ Result_value (String value); Result_value (String separator); Result_value (Int limit) ] -> - (match bind_string_list context db output_var (split_string_limited value separator limit) bindings with - | Some bindings -> [ bindings ] - | None -> []) - | Some [ Result_value (String value); Result_value (Regex pattern); Result_value (Int limit) ] -> - (match bind_string_list context db output_var (split_regex_limited value pattern limit) bindings with - | Some bindings -> [ bindings ] - | None -> []) + | Some [ Result_value (String value); Result_value (String separator); Result_value (Int64 limit) ] -> + (match Util.int64_to_int limit with + | Some limit -> bind_string_list context db output_var (split_string_limited value separator limit) bindings + | None -> bind_string_list context db output_var (split_string value separator) bindings) + |> Option.to_list + | Some [ Result_value (String value); Result_value (Regex pattern); Result_value (Int64 limit) ] -> + (match Util.int64_to_int limit with + | Some limit -> bind_string_list context db output_var (split_regex_limited value pattern limit) bindings + | None -> bind_string_list context db output_var (split_regex value pattern) bindings) + |> Option.to_list | Some _ | None -> [] let eval_string_split_lines_clause context db bindings value_term output_var = @@ -717,25 +720,25 @@ let range_values = Built_ins.range_values let eval_range_values context db bindings output_var start_value end_value step = range_values start_value end_value step - |> List.filter_map (fun value -> bind_var (context.result_resolution_context db) output_var (Result_value (Int value)) bindings) + |> List.filter_map (fun value -> bind_var (context.result_resolution_context db) output_var (Result_value (Int64 value)) bindings) let eval_range_end_value_clause context db bindings end_term output_var = match collect_query_terms (context.match_context db) bindings [ end_term ] with | None -> [] - | Some [ Result_value (Int end_value) ] -> eval_range_values context db bindings output_var 0 end_value 1 + | Some [ Result_value (Int64 end_value) ] -> eval_range_values context db bindings output_var 0L end_value 1L | Some _ -> invalid_arg "range requires integer bounds" let eval_range_value_clause context db bindings start_term end_term output_var = match collect_query_terms (context.match_context db) bindings [ start_term; end_term ] with | None -> [] - | Some [ Result_value (Int start_value); Result_value (Int end_value) ] -> - eval_range_values context db bindings output_var start_value end_value 1 + | Some [ Result_value (Int64 start_value); Result_value (Int64 end_value) ] -> + eval_range_values context db bindings output_var start_value end_value 1L | Some _ -> invalid_arg "range requires integer bounds" let eval_range_step_value_clause context db bindings start_term end_term step_term output_var = match collect_query_terms (context.match_context db) bindings [ start_term; end_term; step_term ] with | None -> [] - | Some [ Result_value (Int start_value); Result_value (Int end_value); Result_value (Int step) ] -> + | Some [ Result_value (Int64 start_value); Result_value (Int64 end_value); Result_value (Int64 step) ] -> eval_range_values context db bindings output_var start_value end_value step | Some _ -> invalid_arg "range requires integer bounds" diff --git a/impl/query_where.ml b/impl/query_where.ml index 2a5ccdd..913c0d6 100644 --- a/impl/query_where.ml +++ b/impl/query_where.ml @@ -417,7 +417,11 @@ end) = struct (match query_result_entity_id db result with | Some entity_id -> Result_entity entity_id | None -> relation_join_key_value result) - | Result_value (Int entity_id | Ref entity_id) -> Result_entity entity_id + | Result_value (Ref entity_id) -> Result_entity entity_id + | Result_value (Int64 entity_id) -> + (match Util.int64_to_int entity_id with + | Some entity_id -> Result_entity entity_id + | None -> relation_join_key_value result) | _ -> relation_join_key_value result let relation_attr_index attrs attr = diff --git a/impl/storage.ml b/impl/storage.ml index f416ab1..075fe02 100644 --- a/impl/storage.ml +++ b/impl/storage.ml @@ -62,7 +62,18 @@ let buffered_node_storage pending_entries = let normalize_stored_datom schema datom = let schema_attr = Schema.schema_attr_by_name schema datom.a in match schema_attr, datom.v with - | Some { value_type = Some RefType; _ }, Int entity_id -> { datom with v = Ref entity_id } + | Some { value_type = Some RefType; _ }, Int64 entity_id -> + (match Util.int64_to_int entity_id with + | Some entity_id -> { datom with v = Ref entity_id } + | None -> datom) + | Some { value_type = Some InstantType; _ }, Int64 millis -> + (* older databases stored plain ints under instant attrs as Instant *) + { datom with v = Instant millis } + | Some { value_type = Some InstantType; _ }, Instant _ -> datom + | _, Instant millis -> + (* older databases stored plain ints as Instant; only db.type/instant + attrs are real dates *) + { datom with v = Int64 millis } | Some { value_type = Some TupleType; _ }, Vector values -> { datom with v = Tuple (List.map (fun value -> Some value) values) } | Some { value_type = Some TupleType; _ }, List values -> @@ -351,7 +362,7 @@ let ref_type_keyword = function let settings (db : db) = let index_settings = PSet.settings db.eavt_index in - [ "branching-factor", Int index_settings.branching_factor + [ "branching-factor", Int64 (Int64.of_int index_settings.branching_factor) ; "ref-type", Keyword (ref_type_keyword index_settings.ref_type) ; "storage", Bool (Option.is_some db.storage_ref) ] diff --git a/impl/transact.ml b/impl/transact.ml index 1161836..4e56a9d 100644 --- a/impl/transact.ml +++ b/impl/transact.ml @@ -153,8 +153,9 @@ let entity_ref_of_ref_attr_value = function | TxRef -> Some CurrentTx | Ref entity_id -> Some (Entity_id entity_id) | Ref_to entity_ref -> Some entity_ref - | Int entity_id when entity_id < 0 -> Some (Temp_id (string_of_int entity_id)) - | Int entity_id -> Some (Entity_id entity_id) + | Int64 entity_id when entity_id < 0L -> Some (Temp_id (Int64.to_string entity_id)) + | Int64 entity_id -> + Option.map (fun entity_id -> Entity_id entity_id) (Util.int64_to_int entity_id) | String tempid -> Some (Temp_id tempid) | Keyword "db/current-tx" -> Some CurrentTx | Keyword ident -> Some (Ident ident) @@ -239,8 +240,9 @@ and map_entries_of_tx_entity (entity : tx_entity) : (value * value) list = | None -> entries and value_of_entity_ref = function - | Entity_id entity_id -> Int entity_id - | Temp_id tempid -> (match int_of_string_opt tempid with Some n -> Int n | None -> String tempid) + | Entity_id entity_id -> Int64 (Int64.of_int entity_id) + | Temp_id tempid -> + (match Int64.of_string_opt tempid with Some n -> Int64 n | None -> String tempid) | Ident ident -> Keyword ident | Lookup_ref (attr, value) -> Vector [ Keyword attr; value ] | CurrentTx -> Keyword "db/current-tx" @@ -1166,7 +1168,7 @@ let apply_tx context tx_ops db = | None -> false | Some value -> has_complex_ref_value value) values - | Nil | Int _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | Ref _ -> false + | Nil | Int64 _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | Ref _ -> false in let unique_attr attr = attr = "db/ident" @@ -1196,7 +1198,7 @@ let apply_tx context tx_ops db = in let simple_lookup_value = function | Nil | Ref_to _ | TxRef | List _ | Vector _ | Map _ | Set _ | Tuple _ -> false - | Int _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | Ref _ -> true + | Int64 _ | Float _ | String _ | Symbol _ | Bool _ | Keyword _ | Uuid _ | Instant _ | Regex _ | Ref _ -> true in let supported_ref_lookup = function | Ref_to (Lookup_ref (lookup_attr, lookup_value)) -> @@ -1208,7 +1210,7 @@ let apply_tx context tx_ops db = && if context.resolve_context.is_ref_attr db attr then match value with - | Ref _ | Int _ -> true + | Ref _ | Int64 _ -> true | value when supported_ref_lookup value -> true | _ -> false else diff --git a/impl/transact_datoms.ml b/impl/transact_datoms.ml index bc1b9de..2515839 100644 --- a/impl/transact_datoms.ml +++ b/impl/transact_datoms.ml @@ -59,7 +59,7 @@ end) = struct | TupleType, Tuple _ -> true | StringType, String _ -> true | KeywordType, Keyword _ -> true - | NumberType, (Int _ | Float _) -> true + | NumberType, (Int64 _ | Float _) -> true | UuidType, Uuid _ -> true | InstantType, Instant _ -> true | _ -> false @@ -99,7 +99,7 @@ end) = struct | _ -> invalid_arg ("keyword attribute requires keyword value: " ^ d.a)) | Some { value_type = Some NumberType; _ } -> (match d.v with - | Int _ | Float _ -> () + | Int64 _ | Float _ -> () | _ -> invalid_arg ("number attribute requires numeric value: " ^ d.a)) | Some { value_type = Some UuidType; _ } -> (match d.v with @@ -280,7 +280,8 @@ end) = struct let coerce_component source_attr value = match value with | Nil -> None - | Int entity_id when is_ref_attr db source_attr -> Some (Ref (validate_entity_id entity_id)) + | Int64 entity_id when is_ref_attr db source_attr -> + Some (Ref (validate_entity_id (Util.int64_to_int_exn "tuple component entity id" entity_id))) | (List [ lookup_attr; lookup_value ] | Vector [ lookup_attr; lookup_value ]) when is_ref_attr db source_attr -> (match Option.bind (lookup_attr_name lookup_attr) (fun attr -> entid_in_datoms db datoms attr lookup_value) with | Some entity_id -> Some (Ref entity_id) @@ -297,7 +298,8 @@ end) = struct let coerce_component source_attr = function | None -> None | Some Nil -> None - | Some (Int entity_id) when is_ref_attr db source_attr -> Some (Ref (validate_entity_id entity_id)) + | Some (Int64 entity_id) when is_ref_attr db source_attr -> + Some (Ref (validate_entity_id (Util.int64_to_int_exn "tuple component entity id" entity_id))) | Some ((List [ lookup_attr; lookup_value ] | Vector [ lookup_attr; lookup_value ]) as lookup_ref) when is_ref_attr db source_attr -> (match Option.bind (lookup_attr_name lookup_attr) (fun attr -> entid_in_datoms db datoms attr lookup_value) with | Some entity_id -> Some (Ref entity_id) diff --git a/impl/util.ml b/impl/util.ml index 43e6f71..ee83d40 100644 --- a/impl/util.ml +++ b/impl/util.ml @@ -7,6 +7,53 @@ let rec list_equal_by equal left right = equal left right && list_equal_by equal left_rest right_rest | [], _ :: _ | _ :: _, [] -> false +let int64_to_int value = + if Int64.compare value (Int64.of_int min_int) >= 0 + && Int64.compare value (Int64.of_int max_int) <= 0 + then Some (Int64.to_int value) + else None + +let int64_to_int_exn label value = + match int64_to_int value with + | Some value -> value + | None -> invalid_arg (label ^ ": int64 out of int range: " ^ Int64.to_string value) + +(* days-from-civil inverse (Howard Hinnant's civil calendar algorithm) *) +let civil_from_days days = + let days = Int64.add days 719468L in + let era = Int64.div (if Int64.compare days 0L >= 0 then days else Int64.sub days 146096L) 146097L in + let day_of_era = Int64.sub days (Int64.mul era 146097L) in + let year_of_era = + Int64.div + (Int64.sub day_of_era (Int64.add (Int64.div day_of_era 1460L) (Int64.sub (Int64.div day_of_era 36524L) (Int64.div day_of_era 146096L)))) + 365L + in + let year = Int64.add year_of_era (Int64.mul era 400L) in + let day_of_year = + Int64.sub day_of_era + (Int64.add (Int64.mul 365L year_of_era) (Int64.sub (Int64.div year_of_era 4L) (Int64.div year_of_era 100L))) + in + let month_prime = Int64.div (Int64.add (Int64.mul 5L day_of_year) 2L) 153L in + let day = Int64.sub day_of_year (Int64.sub (Int64.div (Int64.add (Int64.mul 153L month_prime) 2L) 5L) 1L) in + let month = if Int64.compare month_prime 10L < 0 then Int64.add month_prime 3L else Int64.sub month_prime 9L in + let year = if Int64.compare month 2L <= 0 then Int64.add year 1L else year in + Int64.to_int year, Int64.to_int month, Int64.to_int day + +(* "YYYY-MM-DDTHH:MM:SS.mmmZ" — the canonical #inst literal form *) +let string_of_instant_millis millis = + let days = + let d = Int64.div millis 86400000L in + (* floor division: shift down when millis is negative and not a whole day *) + if Int64.compare millis 0L < 0 && Int64.rem millis 86400000L <> 0L then Int64.sub d 1L else d + in + let rem = Int64.sub millis (Int64.mul days 86400000L) in + let year, month, day = civil_from_days days in + let hour = Int64.to_int (Int64.div rem 3600000L) in + let minute = Int64.to_int (Int64.div (Int64.rem rem 3600000L) 60000L) in + let second = Int64.to_int (Int64.div (Int64.rem rem 60000L) 1000L) in + let ms = Int64.to_int (Int64.rem rem 1000L) in + Printf.sprintf "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ" year month day hour minute second ms + let rec entity_ref_equal left right = match left, right with | Entity_id left, Entity_id right -> left = right @@ -20,7 +67,7 @@ let rec entity_ref_equal left right = and value_equal left right = match left, right with | Nil, Nil -> true - | Int left, Int right -> left = right + | Int64 left, Int64 right -> Int64.equal left right | Float left, Float right -> (classify_float left = FP_nan && classify_float right = FP_nan) || left = right | String left, String right -> left = right @@ -247,7 +294,7 @@ let rec clojure_hasheq = function | Nil -> 0 | Bool true -> 1231 | Bool false -> 1237 - | Int value -> murmur3_hash_long (Int64.of_int value) + | Int64 value -> murmur3_hash_long value | Float value -> Hashtbl.hash value | String value -> murmur3_hash_int (java_string_hash value) | Symbol value -> clojure_symbol_hash value @@ -279,7 +326,7 @@ let value_type_rank = function | Vector _ -> 6 | Tuple _ -> 7 | Bool _ -> 8 - | Int _ | Float _ | Ref _ -> 9 + | Int64 _ | Float _ | Ref _ -> 9 | String _ -> 10 | Regex _ -> 11 | Instant _ -> 12 @@ -289,17 +336,17 @@ let value_type_rank = function let rec compare_value left right = match left, right with - | Int left, Int right -> compare left right + | Int64 left, Int64 right -> Int64.compare left right | Float left, Float right -> compare left right - | Int left, Float right -> compare (float_of_int left) right - | Float left, Int right -> compare left (float_of_int right) + | Int64 left, Float right -> compare (Int64.to_float left) right + | Float left, Int64 right -> compare left (Int64.to_float right) | Ref left, Ref right -> compare left right - | Int left, Ref right -> compare left right - | Ref left, Int right -> compare left right + | Int64 left, Ref right -> Int64.compare left (Int64.of_int right) + | Ref left, Int64 right -> Int64.compare (Int64.of_int left) right | Float left, Ref right -> compare left (float_of_int right) | Ref left, Float right -> compare (float_of_int left) right - | Instant left, Int right -> Int64.compare left (Int64.of_int right) - | Int left, Instant right -> Int64.compare (Int64.of_int left) right + | Instant left, Int64 right -> Int64.compare left right + | Int64 left, Instant right -> Int64.compare left right | Instant left, Ref right -> Int64.compare left (Int64.of_int right) | Ref left, Instant right -> Int64.compare (Int64.of_int left) right | Instant left, Float right -> compare (Int64.to_float left) right diff --git a/impl/util.mli b/impl/util.mli index b09ff8b..1837bd7 100644 --- a/impl/util.mli +++ b/impl/util.mli @@ -11,3 +11,7 @@ val first_nonzero : int list -> int val compare_datom : index -> datom -> datom -> int val normalize_value : value -> value val normalize_datom_value : datom -> datom +val int64_to_int : int64 -> int option +val int64_to_int_exn : string -> int64 -> int +val civil_from_days : int64 -> int * int * int +val string_of_instant_millis : int64 -> string diff --git a/js/datascript_js.ml b/js/datascript_js.ml index 8373955..1353a1e 100644 --- a/js/datascript_js.ml +++ b/js/datascript_js.ml @@ -102,8 +102,8 @@ let schema_of_json = function let rec value_of_json = function | `Null -> Nil | `Bool value -> Bool value - | `Int value -> Int value - | `Intlit value -> Int (int_of_string value) + | `Int value -> Int64 (Int64.of_int value) + | `Intlit value -> Int64 (Int64.of_string value) | `Float value -> Float value | `String value when String.starts_with ~prefix:":" value -> Keyword (attr_name value) | `String value -> String value @@ -131,7 +131,10 @@ let schema_attr_is_ref db attr = let value_of_json_for_attr ?db attr json = match value_of_json json with - | Int entity_id when schema_attr_is_ref db attr -> Ref entity_id + | Int64 entity_id when schema_attr_is_ref db attr -> + (match Util.int64_to_int entity_id with + | Some entity_id -> Ref entity_id + | None -> Int64 entity_id) | value -> value let tx_value_of_json_for_attr ?db attr = function @@ -143,8 +146,8 @@ let entity_ref_of_json = function | `Int entity_id when entity_id < 0 -> Temp_id (string_of_int entity_id) | `Int entity_id -> Entity_id entity_id | `Intlit value -> - let entity_id = int_of_string value in - if entity_id < 0 then Temp_id value else Entity_id entity_id + let entity_id = Int64.of_string value in + if entity_id < 0L then Temp_id value else Entity_id (Util.int64_to_int_exn "entity id" entity_id) | `String "db/current-tx" | `String ":db/current-tx" -> CurrentTx | `String value when String.starts_with ~prefix:":" value -> Ident (attr_name value) | `String value -> Temp_id value @@ -210,7 +213,7 @@ let datoms_of_json = function let rec json_of_value = function | Nil -> `Null - | Int value -> `Int value + | Int64 value -> `Intlit (Int64.to_string value) | Float value -> `Float value | String value -> `String value | Symbol value -> `String value diff --git a/lg/datascript_lg.ml b/lg/datascript_lg.ml index f00ffa6..9a79017 100644 --- a/lg/datascript_lg.ml +++ b/lg/datascript_lg.ml @@ -19,16 +19,11 @@ let of_edn value = | E.Nil -> D.QueryFormNil | E.Bool value -> D.QueryFormBool value | E.String value -> D.QueryFormString value - | E.Char value -> D.QueryFormInt (Uchar.to_int value) + | E.Char value -> D.QueryFormInt (Int64.of_int (Uchar.to_int value)) | E.Symbol value -> D.QueryFormSymbol value | E.Keyword value -> D.QueryFormKeyword value - | E.Small_int value -> D.QueryFormInt value - | E.Int value -> - if - Int64.compare value (Int64.of_int min_int) < 0 - || Int64.compare value (Int64.of_int max_int) > 0 - then fail path "integer is outside this target's DataScript int range"; - D.QueryFormInt (Int64.to_int value) + | E.Small_int value -> D.QueryFormInt (Int64.of_int value) + | E.Int value -> D.QueryFormInt value | E.Bigint value -> tagged "bigint" value | E.Decimal value -> tagged "decimal" value | E.Ratio value -> tagged "ratio" value @@ -57,7 +52,7 @@ let of_edn value = D.QueryFormTagged (tag, convert (path ^ ".tagged") value) | E.Int_vector values -> D.QueryFormVector - (Array.to_list (Array.map (fun value -> D.QueryFormInt value) values)) + (Array.to_list (Array.map (fun value -> D.QueryFormInt (Int64.of_int value)) values)) | E.Int4_vector (a, b, value, c) -> packed path a b value c | E.Int4_array (a, b, values, c) -> let length = Array.length a in @@ -80,10 +75,10 @@ let of_edn value = and packed path a b value c = D.QueryFormVector [ - D.QueryFormInt a; - D.QueryFormInt b; + D.QueryFormInt (Int64.of_int a); + D.QueryFormInt (Int64.of_int b); convert (at path 2) value; - D.QueryFormInt c; + D.QueryFormInt (Int64.of_int c); ] in try protect (fun () -> convert "$" value) @@ -118,8 +113,14 @@ module Codec = struct let int = { - encode = (fun value -> D.Int value); - decode = (function D.Int value -> Ok value | _ -> mismatch "int"); + encode = (fun value -> D.Int64 (Int64.of_int value)); + decode = + (function + | D.Int64 value -> + (match D.Util.int64_to_int value with + | Some value -> Ok value + | None -> mismatch "int") + | _ -> mismatch "int"); } let float = @@ -128,7 +129,7 @@ module Codec = struct decode = (function | D.Float value -> Ok value - | D.Int value -> Ok (float_of_int value) + | D.Int64 value -> Ok (Int64.to_float value) | _ -> mismatch "float"); } diff --git a/melange/datascript_melange_storage.ml b/melange/datascript_melange_storage.ml index 59ad195..59f1f66 100644 --- a/melange/datascript_melange_storage.ml +++ b/melange/datascript_melange_storage.ml @@ -176,16 +176,14 @@ let schema_of_transit = function let rec value_to_transit = function | Ds.Nil -> Transit.Null - | Int value -> Transit.Int value + | Int64 value -> Transit.Int64 value | Float value -> Transit.Float value | String value -> Transit.String value | Symbol value -> Transit.Symbol value | Bool value -> Transit.Bool value | Keyword value -> Transit.Keyword value | Uuid value -> Transit.Uuid value - | Instant value -> Transit.Int64 value - (* int64-range scalars (ms timestamps) stay integers on the wire; - cljs writes plain numbers (~i), not dates, for these values *) + | Instant value -> Transit.Date value | Regex value -> Transit.Tagged ("regex", Transit.String value) | Ref entity_id -> Transit.Int entity_id | List values -> Transit.List (List.map value_to_transit values) @@ -207,17 +205,12 @@ let rec value_of_transit = function | Transit.Null -> Ds.Nil | Bool value -> Bool value | String value -> String value - | Int value -> Int value - | Int64 value -> - if - Int64.compare value (Int64.of_int min_int) >= 0 - && Int64.compare value (Int64.of_int max_int) <= 0 - then Int (Int64.to_int value) - else Instant value + | Int value -> Int64 (Int64.of_int value) + | Int64 value -> Int64 value | Float value -> Float value | Binary value -> String value | Big_decimal value -> Float (float_of_string value) - | Big_int value -> Transit.Int64 (Int64.of_string value) |> value_of_transit + | Big_int value -> Int64 (Int64.of_string value) | Date value -> Instant value | Uuid value -> Uuid value | Uri value -> String value diff --git a/sqlite/datascript_sqlite_codec.ml b/sqlite/datascript_sqlite_codec.ml index 4cb7ffd..cb28d3d 100644 --- a/sqlite/datascript_sqlite_codec.ml +++ b/sqlite/datascript_sqlite_codec.ml @@ -176,16 +176,14 @@ let schema_of_transit = function let rec value_to_transit = function | Ds.Nil -> Transit.Null - | Int value -> Transit.Int value + | Int64 value -> Transit.Int64 value | Float value -> Transit.Float value | String value -> Transit.String value | Symbol value -> Transit.Symbol value | Bool value -> Transit.Bool value | Keyword value -> Transit.Keyword value | Uuid value -> Transit.Uuid value - | Instant value -> Transit.Int64 value - (* int64-range scalars (ms timestamps) stay integers on the wire; - cljs writes plain numbers (~i), not dates, for these values *) + | Instant value -> Transit.Date value | Regex value -> Transit.Tagged ("regex", Transit.String value) | Ref entity_id -> Transit.Int entity_id | List values -> Transit.List (List.map value_to_transit values) @@ -207,17 +205,12 @@ let rec value_of_transit = function | Transit.Null -> Ds.Nil | Bool value -> Bool value | String value -> String value - | Int value -> Int value - | Int64 value -> - if - Int64.compare value (Int64.of_int min_int) >= 0 - && Int64.compare value (Int64.of_int max_int) <= 0 - then Int (Int64.to_int value) - else Instant value + | Int value -> Int64 (Int64.of_int value) + | Int64 value -> Int64 value | Float value -> Float value | Binary value -> String value | Big_decimal value -> Float (float_of_string value) - | Big_int value -> Transit.Int64 (Int64.of_string value) |> value_of_transit + | Big_int value -> Int64 (Int64.of_string value) | Date value -> Instant value | Uuid value -> Uuid value | Uri value -> String value diff --git a/test/cross_runtime_ocaml.ml b/test/cross_runtime_ocaml.ml index 3190de0..84a67ab 100644 --- a/test/cross_runtime_ocaml.ml +++ b/test/cross_runtime_ocaml.ml @@ -71,14 +71,14 @@ let schema_json db = let rec value_json = function | Nil -> json_null - | Int value -> json_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> json_string value | Symbol value -> json_string value | Bool value -> json_bool value | Keyword value -> json_string (":" ^ value) | Uuid value -> json_string value - | Instant value -> json_int (Int64.to_int value) + | Instant value -> Int64.to_string value | Regex value -> json_string value | Ref value -> json_int value | List values | Vector values | Set values -> json_list (List.map value_json values) @@ -194,7 +194,7 @@ let fuzz_generated_batch i = let score = 10 + ((i * 17) mod 90) in let ops = [ Add (fuzz_lookup source, "tag", String tag) - ; Add (fuzz_lookup source, "score", Int score) + ; Add (fuzz_lookup source, "score", Int64 (Int64.of_int score)) ] in let ops = @@ -322,14 +322,14 @@ let () = { db_id = Some (Temp_id "-1") ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 31) + ; "age", One_value (Int64 31L) ; "aka", Many_values [ String "Vanya"; String "I" ] ; "friend", One_value (Ref_to (Temp_id "-2")) ] } ; Entity { db_id = Some (Temp_id "-2") - ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] + ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } ] in @@ -345,7 +345,7 @@ let () = let second_report = transact_conn conn - [ Add (Entity_id 1, "age", Int 32); Retract (Entity_id 1, "aka", Some (String "I")) ] + [ Add (Entity_id 1, "age", Int64 32L); Retract (Entity_id 1, "aka", Some (String "I")) ] in let second_db = second_report.db_after in emit "tx.second.datoms" (datoms_json second_report.tx_data); diff --git a/test/dune b/test/dune index 4fd498e..0dcaac5 100644 --- a/test/dune +++ b/test/dune @@ -3,6 +3,11 @@ (modules test_datascript) (libraries datascript-ocaml-native unix)) +(test + (name test_int64) + (modules test_int64) + (libraries datascript-ocaml-native datascript-ocaml-native.sqlite melange-transit-native unix)) + (test (name test_lru) (modules test_lru) diff --git a/test/js_smoke.ml b/test/js_smoke.ml index 7feca30..2b00151 100644 --- a/test/js_smoke.ml +++ b/test/js_smoke.ml @@ -24,10 +24,10 @@ let () = ( Ident "touch" , fun _ args -> match args with - | [ Int entity_id ] -> [ Add (Entity_id entity_id, "touched", Bool true) ] + | [ Int64 entity_id ] -> [ Add (Entity_id (Util.int64_to_int_exn "entity id" entity_id), "touched", Bool true) ] | _ -> invalid_arg "touch expects one entity id" ) ] - |> db_with [ CallIdent (Ident "touch", [ Int 1 ]) ] + |> db_with [ CallIdent (Ident "touch", [ Int64 1L ]) ] in match datoms db Eavt ~e:1 ~a:"touched" () with | [ { v = Bool true; _ } ] -> () diff --git a/test/sqlite_cross_runtime_native.ml b/test/sqlite_cross_runtime_native.ml index 58c114a..a9d3e16 100644 --- a/test/sqlite_cross_runtime_native.ml +++ b/test/sqlite_cross_runtime_native.ml @@ -95,8 +95,8 @@ let schema_of_json = function let rec value_of_json = function | `Null -> Nil | `Bool value -> Bool value - | `Int value -> Int value - | `Intlit value -> Int (int_of_string value) + | `Int value -> Int64 (Int64.of_int value) + | `Intlit value -> Int64 (Int64.of_string value) | `Float value -> Float value | `String value when String.length value > 0 && value.[0] = ':' -> Keyword (attr_name value) | `String value -> String value @@ -124,7 +124,7 @@ let tx_batch_of_json = function let string_of_value = function | Nil -> "nil" - | Int value -> "int:" ^ string_of_int value + | Int64 value -> "int:" ^ Int64.to_string value | Float value -> "float:" ^ string_of_float value | String value -> "string:" ^ value | Symbol value -> "symbol:" ^ value diff --git a/test/test_built_ins.ml b/test/test_built_ins.ml index 17875c0..dcb74e4 100644 --- a/test/test_built_ins.ml +++ b/test/test_built_ins.ml @@ -46,21 +46,21 @@ let test_eval_arithmetic () = assert_equal_value_option "addition preserves float results" (Some (Float 3.5)) - (Built_ins.eval_arithmetic AddNumbers [ Int 1; Float 2.5 ]); + (Built_ins.eval_arithmetic AddNumbers [ Int64 1L; Float 2.5 ]); assert_equal_value_option "division returns an integer when the quotient is integral" - (Some (Int 2)) - (Built_ins.eval_arithmetic DivideNumbers [ Int 4; Int 2 ]); + (Some (Int64 2L)) + (Built_ins.eval_arithmetic DivideNumbers [ Int64 4L; Int64 2L ]); assert_equal_value_option "division returns a float when the quotient is fractional" (Some (Float 2.5)) - (Built_ins.eval_arithmetic DivideNumbers [ Int 5; Int 2 ]); + (Built_ins.eval_arithmetic DivideNumbers [ Int64 5L; Int64 2L ]); assert_equal_value_option "modulo follows Clojure sign semantics" - (Some (Int 1)) - (Built_ins.eval_arithmetic ModuloNumbers [ Int (-3); Int 2 ]); + (Some (Int64 1L)) + (Built_ins.eval_arithmetic ModuloNumbers [ Int64 (-3L); Int64 2L ]); assert_raises_invalid_arg "integer arithmetic rejects floats" (fun () -> - ignore (Built_ins.eval_arithmetic RemainderNumbers [ Float 3.0; Int 2 ])) + ignore (Built_ins.eval_arithmetic RemainderNumbers [ Float 3.0; Int64 2L ])) let test_normalized_comparison () = assert_equal_int "negative comparison normalizes to -1" (-1) (Built_ins.normalized_comparison (-10)); @@ -74,8 +74,8 @@ let test_extremum_value () = (Built_ins.extremum_value MinimumValue (Keyword "b") [ Keyword "a"; Keyword "c" ]); assert_equal_value "maximum uses DataScript value ordering" - (Int 9) - (Built_ins.extremum_value MaximumValue (Int 3) [ Int 9; Int 4 ]) + (Int64 9L) + (Built_ins.extremum_value MaximumValue (Int64 3L) [ Int64 9L; Int64 4L ]) let test_string_helpers () = assert_equal_bool @@ -203,16 +203,16 @@ let test_string_helpers () = let test_aggregate_result () = let values = - [ Result_value (Int 1); Result_value (Int 2); Result_value (Int 2); Result_value (Float 3.5) ] + [ Result_value (Int64 1L); Result_value (Int64 2L); Result_value (Int64 2L); Result_value (Float 3.5) ] in - assert_equal_result "count counts all rows" (Result_value (Int 4)) (Built_ins.aggregate_result Count values); + assert_equal_result "count counts all rows" (Result_value (Int64 4L)) (Built_ins.aggregate_result Count values); assert_equal_result "count-distinct counts unique query results" - (Result_value (Int 3)) + (Result_value (Int64 3L)) (Built_ins.aggregate_result CountDistinct values); assert_equal_result "distinct returns a normalized set of scalar values" - (Result_value (Set [ Int 1; Int 2; Float 3.5 ])) + (Result_value (Set [ Int64 1L; Int64 2L; Float 3.5 ])) (Built_ins.aggregate_result Distinct values); assert_equal_result "sum preserves float totals" (Result_value (Float 8.5)) (Built_ins.aggregate_result Sum values); assert_equal_result "avg returns a float" (Result_value (Float 2.125)) (Built_ins.aggregate_result Avg values); @@ -226,7 +226,7 @@ let test_aggregate_result () = (Built_ins.aggregate_result Variance values); assert_equal_result "min uses aggregate result ordering" - (Result_value (Int 1)) + (Result_value (Int64 1L)) (Built_ins.aggregate_result Min values); assert_equal_result "max uses aggregate result ordering" @@ -234,11 +234,11 @@ let test_aggregate_result () = (Built_ins.aggregate_result Max values); assert_equal_result "min n returns an ordered tuple" - (Result_value (Tuple [ Some (Int 1); Some (Int 2) ])) + (Result_value (Tuple [ Some (Int64 1L); Some (Int64 2L) ])) (Built_ins.aggregate_result (MinN 2) values); assert_equal_result "max n returns an ordered tuple" - (Result_value (Tuple [ Some (Int 2); Some (Float 3.5) ])) + (Result_value (Tuple [ Some (Int64 2L); Some (Float 3.5) ])) (Built_ins.aggregate_result (MaxN 2) values); assert_raises_invalid_arg "avg rejects empty input" (fun () -> ignore (Built_ins.aggregate_result Avg [])); diff --git a/test/test_conn.ml b/test/test_conn.ml index bca0556..0f02467 100644 --- a/test/test_conn.ml +++ b/test/test_conn.ml @@ -40,7 +40,7 @@ let unique_identity = } let conn_datoms = - [ datom ~e:1 ~a:"age" ~v:(Int 17) () + [ datom ~e:1 ~a:"age" ~v:(Int64 17L) () ; datom ~e:1 ~a:"name" ~v:(String "Ivan") () ] @@ -55,22 +55,22 @@ let test_conn__test_ways_to_create_conn () = assert_conn "conn_from_datoms" [] - [ 1, "age", Int 17; 1, "name", String "Ivan" ] + [ 1, "age", Int64 17L; 1, "name", String "Ivan" ] (conn_from_datoms conn_datoms); assert_conn "conn_from_datoms with schema" [ "aka", many ] - [ 1, "age", Int 17; 1, "name", String "Ivan" ] + [ 1, "age", Int64 17L; 1, "name", String "Ivan" ] (conn_from_datoms ~schema:[ "aka", many ] conn_datoms); assert_conn "conn_from_db" [] - [ 1, "age", Int 17; 1, "name", String "Ivan" ] + [ 1, "age", Int64 17L; 1, "name", String "Ivan" ] (conn_from_db (init_db conn_datoms)); assert_conn "conn_from_db with schema" [ "aka", many ] - [ 1, "age", Int 17; 1, "name", String "Ivan" ] + [ 1, "age", Int64 17L; 1, "name", String "Ivan" ] (conn_from_db (init_db ~schema:[ "aka", many ] conn_datoms)) let test_conn__test_reset_conn_bang () = @@ -78,7 +78,7 @@ let test_conn__test_reset_conn_bang () = let report = ref None in ignore (listen_auto conn (fun tx_report -> report := Some tx_report)); let replacement_datoms = - [ datom ~e:1 ~a:"age" ~v:(Int 20) () + [ datom ~e:1 ~a:"age" ~v:(Int64 20L) () ; datom ~e:1 ~a:"sex" ~v:(Keyword "male") () ] in @@ -86,11 +86,11 @@ let test_conn__test_reset_conn_bang () = let reset_db = reset_conn_bang ~tx_meta:[ "meta", Bool true ] conn replacement in assert_equal_triples "reset_conn_bang returns the replacement db" - [ 1, "age", Int 20; 1, "sex", Keyword "male" ] + [ 1, "age", Int64 20L; 1, "sex", Keyword "male" ] (datoms reset_db Eavt ()); assert_equal_triples "reset_conn_bang updates conn db" - [ 1, "age", Int 20; 1, "sex", Keyword "male" ] + [ 1, "age", Int64 20L; 1, "sex", Keyword "male" ] (datoms (conn_db conn) Eavt ()); if schema (conn_db conn) <> [ "email", unique_identity ] then failwith "reset_conn_bang should update schema"; @@ -99,17 +99,17 @@ let test_conn__test_reset_conn_bang () = | Some report -> assert_equal_triples "reset report exposes db-before" - [ 1, "age", Int 17; 1, "name", String "Ivan" ] + [ 1, "age", Int64 17L; 1, "name", String "Ivan" ] (datoms report.db_before Eavt ()); assert_equal_triples "reset report exposes db-after" - [ 1, "age", Int 20; 1, "sex", Keyword "male" ] + [ 1, "age", Int64 20L; 1, "sex", Keyword "male" ] (datoms report.db_after Eavt ()); assert_equal_tx_flags "reset report tx-data retracts old datoms and adds new datoms" - [ 1, "age", Int 17, false + [ 1, "age", Int64 17L, false ; 1, "name", String "Ivan", false - ; 1, "age", Int 20, true + ; 1, "age", Int64 20L, true ; 1, "sex", Keyword "male", true ] report.tx_data; diff --git a/test/test_core.ml b/test/test_core.ml index 056d918..7e49c9f 100644 --- a/test/test_core.ml +++ b/test/test_core.ml @@ -42,7 +42,7 @@ let test_core__test_protocols () = { db_id = Some (Entity_id 2) ; attrs = [ "name", One_value (String "Petr") - ; "age", One_value (Int 37) + ; "age", One_value (Int64 37L) ; "huh?", One_value (Bool false) ] } @@ -57,7 +57,7 @@ let test_core__test_protocols () = [ 1, "aka", String "IV" ; 1, "aka", String "Terrible" ; 1, "name", String "Ivan" - ; 2, "age", Int 37 + ; 2, "age", Int64 37L ; 2, "huh?", Bool false ; 2, "name", String "Petr" ] diff --git a/test/test_datascript.ml b/test/test_datascript.ml index e5c068f..ddb2e1b 100644 --- a/test/test_datascript.ml +++ b/test/test_datascript.ml @@ -39,7 +39,7 @@ let str_key name = String name let rec debug_value = function | Nil -> "nil" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> Printf.sprintf "%S" value | Symbol value -> value @@ -253,17 +253,17 @@ let test_init_db_preserves_raw_int_datoms_for_ref_attrs () = init_db ~schema:[ "friend", ref_attr ] [ datom ~e:1 ~a:"name" ~v:(String "Ivan") () - ; datom ~e:1 ~a:"friend" ~v:(Int 2) () + ; datom ~e:1 ~a:"friend" ~v:(Int64 2L) () ; datom ~e:2 ~a:"name" ~v:(String "Petr") () ] in assert_equal_datoms "init_db should preserve raw numeric datom values under ref schema like upstream d/datom" - [ datom ~e:1 ~a:"friend" ~v:(Int 2) () ] + [ datom ~e:1 ~a:"friend" ~v:(Int64 2L) () ] (datoms db Eavt ~e:1 ~a:"friend" ()); assert_equal_query "q should expose init_db raw numeric ref-attr datoms as scalar values" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q_string db "[:find ?friend :where [1 :friend ?friend]]") let test_datoms_returns_lazy_sequence () = @@ -289,7 +289,7 @@ let test_datoms_returns_lazy_sequence () = let test_datoms_slices_before_filtered_predicate () = let db = init_db - [ datom ~e:1 ~a:"age" ~v:(Int 30) () + [ datom ~e:1 ~a:"age" ~v:(Int64 30L) () ; datom ~e:2 ~a:"name" ~v:(String "Petr") () ] in @@ -331,7 +331,7 @@ let test_wildcard_pull_plan_uses_entity_slices () = [ [ Result_pull { pulled_id = 1 ; pulled_attrs = - [ Keyword "db/id", Pulled_scalar (Int 1) + [ Keyword "db/id", Pulled_scalar (Int64 1L) ; Keyword "marker", Pulled_scalar (Bool true) ; Keyword "name", Pulled_scalar (String "Ivan") ] @@ -355,17 +355,17 @@ let test_raw_datom_counts_ref_values_in_max_eid () = let db = empty_db ~schema:[ "friend", ref_attr ] () |> db_with - [ Raw_datom (datom ~e:1 ~a:"friend" ~v:(Int 2) ()) + [ Raw_datom (datom ~e:1 ~a:"friend" ~v:(Int64 2L) ()) ; Raw_datom (datom ~e:2 ~a:"name" ~v:(String "Petr") ()) ] in assert_equal_datoms "Raw_datom should preserve raw numeric values under ref schema like upstream d/datom" - [ datom ~e:1 ~a:"friend" ~v:(Int 2) () ] + [ datom ~e:1 ~a:"friend" ~v:(Int64 2L) () ] (datoms db Eavt ~e:1 ~a:"friend" ()); assert_equal_query "q should expose Raw_datom raw numeric ref-attr values as scalars" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q_string db "[:find ?friend :where [1 :friend ?friend]]") let test_raw_datom_counts_tx_in_max_tx () = @@ -384,13 +384,13 @@ let test_transact__test_with_datoms () = empty_db () |> db_with [ Raw_datom (datom ~e:1 ~a:"name" ~v:(String "Oleg") ()) - ; Raw_datom (datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int 17) ()) + ; Raw_datom (datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int64 17L) ()) ; Raw_datom (datom ~tx:(tx0 + 2) ~e:1 ~a:"aka" ~v:(String "x") ()) ] in assert_equal_datoms "Raw_datom assertions keep their own transaction numbers" - [ datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int 17) () + [ datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int64 17L) () ; datom ~tx:(tx0 + 2) ~e:1 ~a:"aka" ~v:(String "x") () ; datom ~e:1 ~a:"name" ~v:(String "Oleg") () ] @@ -399,13 +399,13 @@ let test_transact__test_with_datoms () = empty_db () |> db_with [ Raw_datom (datom ~e:1 ~a:"name" ~v:(String "Oleg") ()) - ; Raw_datom (datom ~e:1 ~a:"age" ~v:(Int 17) ()) + ; Raw_datom (datom ~e:1 ~a:"age" ~v:(Int64 17L) ()) ; Raw_datom (datom ~added:false ~e:1 ~a:"name" ~v:(String "Oleg") ()) ] in assert_equal_datoms "Raw_datom retractions remove matching active facts" - [ datom ~e:1 ~a:"age" ~v:(Int 17) () ] + [ datom ~e:1 ~a:"age" ~v:(Int64 17L) () ] (datoms db Eavt ()) let test_find_datom_returns_first_index_match () = @@ -474,7 +474,7 @@ let test_incremental_writes_keep_public_datoms_indexes_correct () = { db_id = Some (Entity_id id) ; attrs = [ "name", One_value (String name) - ; "age", One_value (Int age) + ; "age", One_value (Int64 (Int64.of_int age)) ; "friend", One_value (Ref friend) ] } @@ -490,13 +490,13 @@ let test_incremental_writes_keep_public_datoms_indexes_correct () = in assert_equal_triples "incremental EAVT remains sorted by entity" - [ 1, "age", Int 30 + [ 1, "age", Int64 30L ; 1, "friend", Ref 2 ; 1, "name", String "Ivan" - ; 2, "age", Int 20 + ; 2, "age", Int64 20L ; 2, "friend", Ref 1 ; 2, "name", String "Petr" - ; 3, "age", Int 40 + ; 3, "age", Int64 40L ; 3, "friend", Ref 1 ; 3, "name", String "Ivan" ] @@ -518,11 +518,11 @@ let test_index_range_returns_avet_values_between_bounds () = let db = empty_db ~schema:[ "age", indexed; "name", indexed ] () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 20) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Sergey"); "age", One_value (Int 7) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "name", One_value (String "Pavel"); "age", One_value (Int 45) ] } - ; Entity { db_id = Some (Entity_id 5); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 20) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 20L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Sergey"); "age", One_value (Int64 7L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "name", One_value (String "Pavel"); "age", One_value (Int64 45L) ] } + ; Entity { db_id = Some (Entity_id 5); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 20L) ] } ] in assert_equal_triples @@ -552,16 +552,16 @@ let test_index_range_returns_avet_values_between_bounds () = (index_range db "name" ()); assert_equal_triples "index_range supports repeated numeric values" - [ 1, "age", Int 15; 2, "age", Int 20; 5, "age", Int 20 ] - (index_range db "age" ~start:(Int 15) ~stop:(Int 20) ()); + [ 1, "age", Int64 15L; 2, "age", Int64 20L; 5, "age", Int64 20L ] + (index_range db "age" ~start:(Int64 15L) ~stop:(Int64 20L) ()); assert_equal_triples "index_range supports wide numeric bounds" - [ 3, "age", Int 7; 1, "age", Int 15; 2, "age", Int 20; 5, "age", Int 20; 4, "age", Int 45 ] - (index_range db "age" ~start:(Int 7) ~stop:(Int 45) ()); + [ 3, "age", Int64 7L; 1, "age", Int64 15L; 2, "age", Int64 20L; 5, "age", Int64 20L; 4, "age", Int64 45L ] + (index_range db "age" ~start:(Int64 7L) ~stop:(Int64 45L) ()); assert_equal_triples "index_range supports numeric bounds outside the indexed values" - [ 3, "age", Int 7; 1, "age", Int 15; 2, "age", Int 20; 5, "age", Int 20; 4, "age", Int 45 ] - (index_range db "age" ~start:(Int 0) ~stop:(Int 100) ()); + [ 3, "age", Int64 7L; 1, "age", Int64 15L; 2, "age", Int64 20L; 5, "age", Int64 20L; 4, "age", Int64 45L ] + (index_range db "age" ~start:(Int64 0L) ~stop:(Int64 100L) ()); assert_raises_invalid_arg "index_range rejects unindexed attrs" (fun () -> ignore (index_range db "alias" ~start:(String "A") ~stop:(String "Z") ())); @@ -600,29 +600,29 @@ let test_indexes_compare_numbers_across_value_constructors () = let db = empty_db ~schema:[ "score", indexed ] () |> db_with - [ Add (Entity_id 1, "score", Int 100) + [ Add (Entity_id 1, "score", Int64 100L) ; Add (Entity_id 2, "score", Float 1.5) - ; Add (Entity_id 3, "score", Int 2) + ; Add (Entity_id 3, "score", Int64 2L) ] in assert_equal_triples "AVET sorts int and float values numerically" - [ 2, "score", Float 1.5; 3, "score", Int 2; 1, "score", Int 100 ] + [ 2, "score", Float 1.5; 3, "score", Int64 2L; 1, "score", Int64 100L ] (datoms db Avet ~a:"score" ()); assert_equal_triples "index_range compares int and float bounds numerically" - [ 3, "score", Int 2 ] + [ 3, "score", Int64 2L ] (index_range db "score" ~start:(Float 1.6) ~stop:(Float 99.9) ()); assert_equal_triples "seek_datoms compares mixed numeric lower bounds numerically" - [ 3, "score", Int 2; 1, "score", Int 100 ] + [ 3, "score", Int64 2L; 1, "score", Int64 100L ] (seek_datoms db Avet ~a:"score" ~v:(Float 1.6) ()) let test_transact__test_compare_numbers_js_issue_404 () = let db = empty_db () |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "num", One_value (Float 42.5) ] } ] - |> db_with [ Retract (Entity_id 1, "num", Some (Int 42)) ] + |> db_with [ Retract (Entity_id 1, "num", Some (Int64 42L)) ] in assert_equal_triples "retracting int 42 must not remove float 42.5" @@ -633,25 +633,25 @@ let test_avet_exact_lookup_compares_entire_sequences () = let db = empty_db ~schema:[ "path", indexed ] () |> db_with - [ Add (Entity_id 1, "path", List [ Int 1; Int 2 ]) - ; Add (Entity_id 2, "path", List [ Int 1; Int 2; Int 3 ]) + [ Add (Entity_id 1, "path", List [ Int64 1L; Int64 2L ]) + ; Add (Entity_id 2, "path", List [ Int64 1L; Int64 2L; Int64 3L ]) ] in let entity_ids value = datoms db Avet ~a:"path" ~v:value () |> List.map (fun datom -> datom.e) in - if entity_ids (List [ Int 1 ]) <> [] then + if entity_ids (List [ Int64 1L ]) <> [] then failwith "AVET exact lookup should not match shorter sequence prefixes"; - if entity_ids (List [ Int 1; Int 1 ]) <> [] then + if entity_ids (List [ Int64 1L; Int64 1L ]) <> [] then failwith "AVET exact lookup should not match different second sequence item"; - if entity_ids (List [ Int 1; Int 2 ]) <> [ 1 ] then + if entity_ids (List [ Int64 1L; Int64 2L ]) <> [ 1 ] then failwith "AVET exact lookup should match the exact shorter sequence"; - if entity_ids (List [ Int 1; Int 2; Int 2 ]) <> [] then + if entity_ids (List [ Int64 1L; Int64 2L; Int64 2L ]) <> [] then failwith "AVET exact lookup should not match a sequence between indexed values"; - if entity_ids (List [ Int 1; Int 2; Int 3 ]) <> [ 2 ] then + if entity_ids (List [ Int64 1L; Int64 2L; Int64 3L ]) <> [ 2 ] then failwith "AVET exact lookup should match the exact longer sequence"; - if entity_ids (List [ Int 1; Int 2; Int 3; Int 4 ]) <> [] then + if entity_ids (List [ Int64 1L; Int64 2L; Int64 3L; Int64 4L ]) <> [] then failwith "AVET exact lookup should not match longer sequence extensions" let test_indexes_compare_mixed_value_types_like_datascript () = @@ -661,7 +661,7 @@ let test_indexes_compare_mixed_value_types_like_datascript () = [ Add (Entity_id 1, "value", String "z") ; Add (Entity_id 2, "value", Keyword "kind/name") ; Add (Entity_id 3, "value", Bool false) - ; Add (Entity_id 4, "value", Int 7) + ; Add (Entity_id 4, "value", Int64 7L) ; Add (Entity_id 5, "value", String "a") ] in @@ -669,15 +669,15 @@ let test_indexes_compare_mixed_value_types_like_datascript () = "AVET sorts mixed value types by DataScript class order" [ 2, "value", Keyword "kind/name" ; 3, "value", Bool false - ; 4, "value", Int 7 + ; 4, "value", Int64 7L ; 5, "value", String "a" ; 1, "value", String "z" ] (datoms db Avet ~a:"value" ()); assert_equal_triples "index_range follows DataScript mixed value type order" - [ 3, "value", Bool false; 4, "value", Int 7 ] - (index_range db "value" ~start:(Bool false) ~stop:(Int 99) ()) + [ 3, "value", Bool false; 4, "value", Int64 7L ] + (index_range db "value" ~start:(Bool false) ~stop:(Int64 99L) ()) let test_avet_excludes_unindexed_scalar_attrs () = let db = @@ -687,7 +687,7 @@ let test_avet_excludes_unindexed_scalar_attrs () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 31) + ; "age", One_value (Int64 31L) ; "friend", One_value (Ref 2) ] } @@ -705,10 +705,10 @@ let test_avet_excludes_unindexed_scalar_attrs () = "AVET includes schema ref attrs even without explicit index flag" [ 1, "friend", Ref 2 ] (datoms db Avet ()); - let db = empty_db ~schema:[ "age", indexed ] () |> db_with [ Add (Entity_id 1, "age", Int 31) ] in + let db = empty_db ~schema:[ "age", indexed ] () |> db_with [ Add (Entity_id 1, "age", Int64 31L) ] in assert_equal_triples "AVET includes indexed scalar attrs" - [ 1, "age", Int 31 ] + [ 1, "age", Int64 31L ] (datoms db Avet ()); assert_raises_invalid_arg "AVET datoms reject unindexed attrs" @@ -763,23 +763,23 @@ let test_seek_datoms_continues_across_avet_attributes () = init_db ~schema:[ "age", indexed; "name", indexed ] [ datom ~e:1 ~a:"name" ~v:(String "Petr") () - ; datom ~e:1 ~a:"age" ~v:(Int 44) () + ; datom ~e:1 ~a:"age" ~v:(Int64 44L) () ; datom ~e:2 ~a:"name" ~v:(String "Ivan") () - ; datom ~e:2 ~a:"age" ~v:(Int 25) () + ; datom ~e:2 ~a:"age" ~v:(Int64 25L) () ; datom ~e:3 ~a:"name" ~v:(String "Sergey") () - ; datom ~e:3 ~a:"age" ~v:(Int 11) () + ; datom ~e:3 ~a:"age" ~v:(Int64 11L) () ] in assert_equal_triples "seek_datoms on AVET starts at the value bound and continues into later attrs" - [ 3, "age", Int 11 - ; 2, "age", Int 25 - ; 1, "age", Int 44 + [ 3, "age", Int64 11L + ; 2, "age", Int64 25L + ; 1, "age", Int64 44L ; 2, "name", String "Ivan" ; 1, "name", String "Petr" ; 3, "name", String "Sergey" ] - (seek_datoms db Avet ~a:"age" ~v:(Int 10) ()); + (seek_datoms db Avet ~a:"age" ~v:(Int64 10L) ()); assert_equal_triples "seek_datoms on AVET uses string prefix bounds" [ 1, "name", String "Petr"; 3, "name", String "Sergey" ] @@ -794,48 +794,48 @@ let test_rseek_datoms_continues_across_avet_attributes () = init_db ~schema:[ "age", indexed; "name", indexed ] [ datom ~e:1 ~a:"name" ~v:(String "Petr") () - ; datom ~e:1 ~a:"age" ~v:(Int 44) () + ; datom ~e:1 ~a:"age" ~v:(Int64 44L) () ; datom ~e:2 ~a:"name" ~v:(String "Ivan") () - ; datom ~e:2 ~a:"age" ~v:(Int 25) () + ; datom ~e:2 ~a:"age" ~v:(Int64 25L) () ; datom ~e:3 ~a:"name" ~v:(String "Sergey") () - ; datom ~e:3 ~a:"age" ~v:(Int 11) () + ; datom ~e:3 ~a:"age" ~v:(Int64 11L) () ] in assert_equal_triples "rseek_datoms on AVET starts at the value bound and continues into earlier attrs" [ 1, "name", String "Petr" ; 2, "name", String "Ivan" - ; 1, "age", Int 44 - ; 2, "age", Int 25 - ; 3, "age", Int 11 + ; 1, "age", Int64 44L + ; 2, "age", Int64 25L + ; 3, "age", Int64 11L ] (rseek_datoms db Avet ~a:"name" ~v:(String "Petr") ()); assert_equal_triples "rseek_datoms on AVET uses the greatest value below a missing bound" - [ 2, "age", Int 25; 3, "age", Int 11 ] - (rseek_datoms db Avet ~a:"age" ~v:(Int 26) ()); + [ 2, "age", Int64 25L; 3, "age", Int64 11L ] + (rseek_datoms db Avet ~a:"age" ~v:(Int64 26L) ()); assert_equal_triples "rseek_datoms on AVET includes the exact upper bound" - [ 2, "age", Int 25; 3, "age", Int 11 ] - (rseek_datoms db Avet ~a:"age" ~v:(Int 25) ()) + [ 2, "age", Int64 25L; 3, "age", Int64 11L ] + (rseek_datoms db Avet ~a:"age" ~v:(Int64 25L) ()) let test_upstream_index_api_parity_batch () = let db = empty_db ~schema:[ "age", indexed; "name", indexed ] () |> db_with [ Add (Entity_id 1, "name", String "Petr") - ; Add (Entity_id 1, "age", Int 44) + ; Add (Entity_id 1, "age", Int64 44L) ; Add (Entity_id 2, "name", String "Ivan") - ; Add (Entity_id 2, "age", Int 25) + ; Add (Entity_id 2, "age", Int64 25L) ; Add (Entity_id 3, "name", String "Sergey") - ; Add (Entity_id 3, "age", Int 11) + ; Add (Entity_id 3, "age", Int64 11L) ] in assert_equal_triples "upstream index parity AEVT sort order" - [ 1, "age", Int 44 - ; 2, "age", Int 25 - ; 3, "age", Int 11 + [ 1, "age", Int64 44L + ; 2, "age", Int64 25L + ; 3, "age", Int64 11L ; 1, "name", String "Petr" ; 2, "name", String "Ivan" ; 3, "name", String "Sergey" @@ -843,19 +843,19 @@ let test_upstream_index_api_parity_batch () = (datoms db Aevt ()); assert_equal_triples "upstream index parity EAVT sort order" - [ 1, "age", Int 44 + [ 1, "age", Int64 44L ; 1, "name", String "Petr" - ; 2, "age", Int 25 + ; 2, "age", Int64 25L ; 2, "name", String "Ivan" - ; 3, "age", Int 11 + ; 3, "age", Int64 11L ; 3, "name", String "Sergey" ] (datoms db Eavt ()); assert_equal_triples "upstream index parity AVET sort order" - [ 3, "age", Int 11 - ; 2, "age", Int 25 - ; 1, "age", Int 44 + [ 3, "age", Int64 11L + ; 2, "age", Int64 25L + ; 1, "age", Int64 44L ; 2, "name", String "Ivan" ; 1, "name", String "Petr" ; 3, "name", String "Sergey" @@ -863,13 +863,13 @@ let test_upstream_index_api_parity_batch () = (datoms db Avet ()); assert_equal_triples "upstream index parity find_datom with empty prefix" - [ 1, "age", Int 44 ] + [ 1, "age", Int64 44L ] (match find_datom db Eavt () with | Some datom -> [ datom ] | None -> []); assert_equal_triples "upstream index parity find_datom with entity prefix" - [ 2, "age", Int 25 ] + [ 2, "age", Int64 25L ] (match find_datom db Eavt ~e:2 () with | Some datom -> [ datom ] | None -> []); @@ -902,21 +902,21 @@ let test_upstream_index_api_parity_batch () = let path_db = empty_db ~schema:[ "path", indexed ] () |> db_with - [ Add (Entity_id 1, "path", List [ Int 1; Int 2 ]) - ; Add (Entity_id 2, "path", List [ Int 1; Int 2; Int 3 ]) + [ Add (Entity_id 1, "path", List [ Int64 1L; Int64 2L ]) + ; Add (Entity_id 2, "path", List [ Int64 1L; Int64 2L; Int64 3L ]) ] in let path_entities value = datoms path_db Avet ~a:"path" ~v:value () |> List.map (fun datom -> datom.e) in - if path_entities (List [ Int 1 ]) <> [] then + if path_entities (List [ Int64 1L ]) <> [] then failwith "AVET sequence exact lookup should reject shorter prefixes"; - if path_entities (List [ Int 1; Int 2 ]) <> [ 1 ] then + if path_entities (List [ Int64 1L; Int64 2L ]) <> [ 1 ] then failwith "AVET sequence exact lookup should match the shorter stored value"; - if path_entities (List [ Int 1; Int 2; Int 3 ]) <> [ 2 ] then + if path_entities (List [ Int64 1L; Int64 2L; Int64 3L ]) <> [ 2 ] then failwith "AVET sequence exact lookup should match the longer stored value"; - if path_entities (List [ Int 1; Int 2; Int 3; Int 4 ]) <> [] then + if path_entities (List [ Int64 1L; Int64 2L; Int64 3L; Int64 4L ]) <> [] then failwith "AVET sequence exact lookup should reject longer extensions" let test_db_with_adds_entities () = @@ -935,7 +935,7 @@ let test_db_with_adds_entities () = { db_id = Some (Entity_id 2) ; attrs = [ "name", One_value (String "Petr") - ; "age", One_value (Int 37) + ; "age", One_value (Int64 37L) ; "active", One_value (Bool false) ] } @@ -947,7 +947,7 @@ let test_db_with_adds_entities () = ; 1, "aka", String "Terrible" ; 1, "name", String "Ivan" ; 2, "active", Bool false - ; 2, "age", Int 37 + ; 2, "age", Int64 37L ; 2, "name", String "Petr" ] (datoms db Eavt ()) @@ -993,7 +993,7 @@ let test_entity_map_db_id_attr_is_not_stored () = [ Entity { db_id = Some (Entity_id 1) ; attrs = - [ "db/id", One_value (Int 99) + [ "db/id", One_value (Int64 99L) ; "name", One_value (String "Ivan") ] } @@ -1205,7 +1205,7 @@ let test_tuple_lookup_refs_resolve_nested_lookup_refs () = (match entity db lookup with | Some entity -> assert_equal_int "tuple lookup ref entity id" 3 entity.id | None -> failwith "expected tuple lookup ref to resolve nested lookup ref"); - (match entity db (Lookup_ref ("ref+name", List [ Int 1; String "Petr" ])) with + (match entity db (Lookup_ref ("ref+name", List [ Int64 1L; String "Petr" ])) with | Some entity -> assert_equal_int "list tuple lookup ref entity id" 3 entity.id | None -> failwith "expected list tuple lookup ref to resolve"); (match @@ -1240,7 +1240,7 @@ let test_edn_tuple_lookup_refs_resolve_nested_lookup_refs () = in assert_equal_triples "EDN list tuple lookup refs resolve nested lookup refs" - [ 3, "age", Int 32 + [ 3, "age", Int64 32L ; 3, "name", String "Petr" ; 3, "ref", Ref 1 ; 3, "ref+name", Tuple [ Some (Ref 1); Some (String "Petr") ] @@ -1310,11 +1310,11 @@ let test_tuple_attrs_support_avet_range_bounds () = let test_tuple_types_validate_direct_tuple_values () = let db = empty_db ~schema:[ "name+score", typed_tuple [ StringType; NumberType ] ] () - |> db_with [ Add (Entity_id 1, "name+score", Tuple [ Some (String "Ivan"); Some (Int 10) ]) ] + |> db_with [ Add (Entity_id 1, "name+score", Tuple [ Some (String "Ivan"); Some (Int64 10L) ]) ] in assert_equal_triples "typed tuple attrs accept matching direct tuple values" - [ 1, "name+score", Tuple [ Some (String "Ivan"); Some (Int 10) ] ] + [ 1, "name+score", Tuple [ Some (String "Ivan"); Some (Int64 10L) ] ] (datoms db Eavt ()); assert_raises_invalid_arg "typed tuple attrs reject wrong arity" @@ -1331,23 +1331,23 @@ let test_tuple_types_validate_direct_tuple_values () = let test_transact__test_db_fn_cas () = let db = empty_db () - |> db_with [ Add (Entity_id 1, "age", Int 31) ] - |> db_with [ CompareAndSet (Entity_id 1, "age", Some (Int 31), Int 32) ] + |> db_with [ Add (Entity_id 1, "age", Int64 31L) ] + |> db_with [ CompareAndSet (Entity_id 1, "age", Some (Int64 31L), Int64 32L) ] in assert_equal_triples "CompareAndSet updates when expected value matches" - [ 1, "age", Int 32 ] + [ 1, "age", Int64 32L ] (datoms db Eavt ()); assert_raises_invalid_arg_message "CompareAndSet reports mismatched cardinality-one values like upstream" ":db.fn/cas failed on datom [1 :age 32], expected 31" - (fun () -> ignore (db_with [ CompareAndSet (Entity_id 1, "age", Some (Int 31), Int 33) ] db)); + (fun () -> ignore (db_with [ CompareAndSet (Entity_id 1, "age", Some (Int64 31L), Int64 33L) ] db)); let db = db_with [ CompareAndSet (Entity_id 1, "nickname", None, String "p") ] db in assert_equal_triples "CompareAndSet can assert missing attributes with expected None" - [ 1, "age", Int 32; 1, "nickname", String "p" ] + [ 1, "age", Int64 32L; 1, "nickname", String "p" ] (datoms db Eavt ()) let test_db_with_compare_and_set_on_many_attr () = @@ -1373,7 +1373,7 @@ let test_transact__test_retract_without_value_issue_339 () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 15) + ; "age", One_value (Int64 15L) ; "aka", Many_values [ String "X"; String "Y"; String "Z" ] ; "friend", One_value (Ref 2) ] @@ -1382,7 +1382,7 @@ let test_transact__test_retract_without_value_issue_339 () = { db_id = Some (Entity_id 2) ; attrs = [ "name", One_value (String "Petr") - ; "age", One_value (Int 37) + ; "age", One_value (Int64 37L) ; "employed", One_value (Bool true) ; "married", One_value (Bool false) ] @@ -1400,7 +1400,7 @@ let test_transact__test_retract_without_value_issue_339 () = in assert_equal_triples "Retract without a value removes true and false values" - [ 1, "age", Int 15; 1, "friend", Ref 2; 2, "age", Int 37; 2, "name", String "Petr" ] + [ 1, "age", Int64 15L; 1, "friend", Ref 2; 2, "age", Int64 37L; 2, "name", String "Petr" ] (datoms retracted Eavt ()); let unchanged = db_with [ Retract (Entity_id 2, "employed", Some (Bool false)) ] db in assert_equal_triples @@ -1409,9 +1409,9 @@ let test_transact__test_retract_without_value_issue_339 () = (datoms unchanged Eavt ~e:2 ~a:"employed" ()) let test_transact__test_uncomparable_issue_356 () = - let map1 = Map [ Keyword "map", Int 1 ] in - let map2 = Map [ Keyword "map", Int 2 ] in - let map3 = Map [ Keyword "map", Int 3 ] in + let map1 = Map [ Keyword "map", Int64 1L ] in + let map2 = Map [ Keyword "map", Int64 2L ] in + let map3 = Map [ Keyword "map", Int64 3L ] in let db = empty_db ~schema:[ "multi", many; "index", indexed ] () in @@ -1467,8 +1467,8 @@ let test_nil_values_are_query_only () = (fun () -> ignore (empty_db () |> db_with [ Add (Entity_id 1, "maybe", Nil) ])) let test_list_values_can_be_indexed_exactly () = - let path12 = List [ Int 1; Int 2 ] in - let path123 = List [ Int 1; Int 2; Int 3 ] in + let path12 = List [ Int64 1L; Int64 2L ] in + let path123 = List [ Int64 1L; Int64 2L; Int64 3L ] in let db = empty_db ~schema:[ "path", indexed ] () |> db_with @@ -1487,12 +1487,12 @@ let test_list_values_can_be_indexed_exactly () = assert_equal_triples "shorter list prefixes are not exact AVET matches" [] - (datoms db Avet ~a:"path" ~v:(List [ Int 1 ]) ()) + (datoms db Avet ~a:"path" ~v:(List [ Int64 1L ]) ()) let test_list_values_use_datascript_length_first_ordering () = - let single_high = List [ Int 2 ] in - let pair_low = List [ Int 1; Int 100 ] in - let pair_high = List [ Int 2; Int 0 ] in + let single_high = List [ Int64 2L ] in + let pair_low = List [ Int64 1L; Int64 100L ] in + let pair_high = List [ Int64 2L; Int64 0L ] in let db = empty_db ~schema:[ "path", indexed ] () |> db_with @@ -1508,15 +1508,15 @@ let test_list_values_use_datascript_length_first_ordering () = assert_equal_triples "index_range uses length-first sequential ordering" [ 1, "path", pair_low; 3, "path", pair_high ] - (index_range db "path" ~start:(List [ Int 0; Int 0 ]) ~stop:(List [ Int 9; Int 9 ]) ()); + (index_range db "path" ~start:(List [ Int64 0L; Int64 0L ]) ~stop:(List [ Int64 9L; Int64 9L ]) ()); assert_equal_triples "seek_datoms uses length-first sequential lower bounds" [ 1, "path", pair_low; 3, "path", pair_high ] - (seek_datoms db Avet ~a:"path" ~v:(List [ Int 0; Int 0 ]) ()) + (seek_datoms db Avet ~a:"path" ~v:(List [ Int64 0L; Int64 0L ]) ()) let test_map_values_are_order_insensitive () = - let ordered = Map [ Keyword "a", Int 1; Keyword "b", Int 2 ] in - let reversed = Map [ Keyword "b", Int 2; Keyword "a", Int 1 ] in + let ordered = Map [ Keyword "a", Int64 1L; Keyword "b", Int64 2L ] in + let reversed = Map [ Keyword "b", Int64 2L; Keyword "a", Int64 1L ] in let db = empty_db ~schema:[ "index", indexed ] () |> db_with [ Add (Entity_id 1, "index", ordered) ] @@ -1532,8 +1532,8 @@ let test_map_values_are_order_insensitive () = (datoms db Eavt ()) let test_init_db_normalizes_map_values () = - let ordered = Map [ Keyword "a", Int 1; Keyword "b", Int 2 ] in - let reversed = Map [ Keyword "b", Int 2; Keyword "a", Int 1 ] in + let ordered = Map [ Keyword "a", Int64 1L; Keyword "b", Int64 2L ] in + let reversed = Map [ Keyword "b", Int64 2L; Keyword "a", Int64 1L ] in let db = init_db ~schema:[ "index", indexed ] @@ -1579,8 +1579,8 @@ let test_init_db_normalizes_set_values () = (datoms db Avet ~a:"tags" ~v:ordered ()) let test_entid_normalizes_unordered_values () = - let ordered_map = Map [ Keyword "a", Int 1; Keyword "b", Int 2 ] in - let reversed_map = Map [ Keyword "b", Int 2; Keyword "a", Int 1 ] in + let ordered_map = Map [ Keyword "a", Int64 1L; Keyword "b", Int64 2L ] in + let reversed_map = Map [ Keyword "b", Int64 2L; Keyword "a", Int64 1L ] in let ordered_set = Set [ Keyword "a"; Keyword "b" ] in let reversed_set = Set [ Keyword "b"; Keyword "a"; Keyword "a" ] in let db = @@ -1616,7 +1616,7 @@ let test_transact__test_transitive_type_compare_issue_386 () = ; String "wRmp6bXAx" ; String "rfL-iQOZm" ; String "tya6s422-" - ; Int 45619 + ; Int64 45619L ] in let db = @@ -1725,8 +1725,8 @@ let test_tempid_shared_between_entity_id_and_ref_values () = { db_id = Some (Temp_id "-2") ; attrs = [ "name", One_value (String "Petr") - ; "friend", One_value (Int (-1)) - ; "parent", One_value (Int (-1)) + ; "friend", One_value (Int64 (-1L)) + ; "parent", One_value (Int64 (-1L)) ] } ] @@ -1828,7 +1828,7 @@ let test_transact__test_db_ident_fn () = ; attrs = [ "db/ident", One_value (Keyword "Petr") ; "name", One_value (String "Petr") - ; "age", One_value (Int 31) + ; "age", One_value (Int64 31L) ] } ; Entity @@ -1842,7 +1842,7 @@ let test_transact__test_db_ident_fn () = | [ String name ] -> (match entid db "name" (String name) with | Some entity_id -> - [ Add (Entity_id entity_id, "age", Int 32) + [ Add (Entity_id entity_id, "age", Int64 32L) ; Add (Entity_id entity_id, "had-birthday", Bool true) ] | None -> invalid_arg ("No entity with name: " ^ name)) @@ -1861,7 +1861,7 @@ let test_transact__test_db_ident_fn () = let db = db_with [ CallIdent (Ident "inc-age", [ String "Petr" ]) ] db in assert_equal_triples "CallIdent invokes db/fn metadata by ident" - [ 1, "age", Int 32 + [ 1, "age", Int64 32L ; 1, "db/ident", Keyword "Petr" ; 1, "had-birthday", Bool true ; 1, "name", String "Petr" @@ -2103,7 +2103,7 @@ let test_upstream_ident_parity_batch () = | Some pulled -> assert_equal_pulled_attrs "ident.cljc pull resolves ident entity refs" - [ kw "db/id", Pulled_scalar (Int 1) + [ kw "db/id", Pulled_scalar (Int64 1L) ; kw "db/ident", Pulled_scalar (Keyword "ent1") ] pulled @@ -2289,13 +2289,13 @@ let test_transact_report_exposes_resolved_tx_datoms () = transact (empty_db ()) [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 31) + ; Add (Entity_id 1, "age", Int64 31L) ] in assert_equal_datoms "tx_data exposes datoms with the transaction id" [ datom ~tx:(tx0 + 1) ~e:1 ~a:"name" ~v:(String "Ivan") () - ; datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int 31) () + ; datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int64 31L) () ] report.tx_data @@ -2405,20 +2405,20 @@ let test_schema_transactions_install_tuple_types () = let test_datoms_filter_by_tx_component () = let db = empty_db () - |> db_with [ Add (Entity_id 1, "age", Int 31) ] - |> db_with [ Add (Entity_id 1, "age", Int 32) ] + |> db_with [ Add (Entity_id 1, "age", Int64 31L) ] + |> db_with [ Add (Entity_id 1, "age", Int64 32L) ] in assert_equal_triples "datoms tx filtering sees current facts only" [] (datoms db Eavt ~tx:(tx0 + 1) ()); (match find_datom db Eavt ~tx:(tx0 + 2) () with - | Some datom -> assert_equal_tx_value "find_datom supports tx component" (Int 32) datom.v + | Some datom -> assert_equal_tx_value "find_datom supports tx component" (Int64 32L) datom.v | None -> failwith "expected tx datom"); assert_equal_triples "seek_datoms supports tx component bounds" - [ 1, "age", Int 32 ] - (seek_datoms db Eavt ~e:1 ~a:"age" ~v:(Int 32) ~tx:(tx0 + 2) ()) + [ 1, "age", Int64 32L ] + (seek_datoms db Eavt ~e:1 ~a:"age" ~v:(Int64 32L) ~tx:(tx0 + 2) ()) let test_reverse_ref_helpers () = if is_reverse_ref "friend" then failwith "plain attr should not be reverse"; @@ -2667,7 +2667,7 @@ let test_upstream_components_and_explode_parity_batch () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 16) + ; "age", One_value (Int64 16L) ; "aka", One_value (List [ String "Devil"; String "Tupen" ]) ; "also", One_value (String "ok") ] @@ -2689,7 +2689,7 @@ let test_upstream_components_and_explode_parity_batch () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "children", One_value (List [ Int (-2); Int (-3) ]) + ; "children", One_value (List [ Int64 (-2L); Int64 (-3L) ]) ] } ; Entity { db_id = Some (Temp_id "-2"); attrs = [ "name", One_value (String "Petr") ] } @@ -2876,13 +2876,13 @@ let test_edn_string_top_level_apis () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 31) + ; "age", One_value (Int64 31L) ; "friend", One_value (Ref 2) ] } ; Entity { db_id = Some (Entity_id 2) - ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 19) ] + ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 19L) ] } ] in @@ -2897,8 +2897,8 @@ let test_edn_string_top_level_apis () = if q_return_map_string db "[:find ?name ?age :keys name age :where [?e :name ?name] [?e :age ?age]]" <> Query_relation_maps - [ [ Keyword "age", Result_value (Int 31); Keyword "name", Result_value (String "Ivan") ] - ; [ Keyword "age", Result_value (Int 19); Keyword "name", Result_value (String "Petr") ] + [ [ Keyword "age", Result_value (Int64 31L); Keyword "name", Result_value (String "Ivan") ] + ; [ Keyword "age", Result_value (Int64 19L); Keyword "name", Result_value (String "Petr") ] ] then failwith "q_return_map_string should parse return map labels and execute query"; (match pull_string db "[:name {:friend [:name]}]" (Entity_id 1) with @@ -2927,13 +2927,13 @@ let test_edn_string_top_level_apis () = let test_query__test_symbol_comparison () = assert_equal_query "query.cljc test-symbol-comparison matches plain symbols in relation sources" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q_sources_string (empty_db ()) [ ( "$" , Relation_source - [ [ Result_value (Int 1); Result_attr "s"; Result_value (Symbol "a") ] - ; [ Result_value (Int 2); Result_attr "s"; Result_value (Symbol "b") ] + [ [ Result_value (Int64 1L); Result_attr "s"; Result_value (Symbol "a") ] + ; [ Result_value (Int64 2L); Result_attr "s"; Result_value (Symbol "b") ] ] ) ] "[:find ?e @@ -3339,7 +3339,7 @@ let test_edn_reader_parses_transaction_and_schema_strings () = in assert_equal_triples "db_with_string stores collection values on cardinality-one attrs" - [ 1, "path", Vector [ Int 1; Int 2 ]; 1, "tags", Set [ Keyword "blue"; Keyword "red" ] ] + [ 1, "path", Vector [ Int64 1L; Int64 2L ]; 1, "tags", Set [ Keyword "blue"; Keyword "red" ] ] (datoms collection_value_db Eavt ~e:1 ~a:"path" () @ datoms collection_value_db Eavt ~e:1 ~a:"tags" ()); assert_equal_triples @@ -3453,9 +3453,9 @@ let test_parse_query_comparison_predicates () = empty_db () |> db_with [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 31) + ; Add (Entity_id 1, "age", Int64 31L) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 17) + ; Add (Entity_id 2, "age", Int64 17L) ] in let query = @@ -3465,7 +3465,7 @@ let test_parse_query_comparison_predicates () = ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormSymbol "?age" ] ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "name"; QueryFormSymbol "?name" ] - ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">"; QueryFormSymbol "?age"; QueryFormInt 18 ] ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">"; QueryFormSymbol "?age"; QueryFormInt 18L ] ] ] in assert_equal_query @@ -3480,7 +3480,7 @@ let test_parse_query_comparison_predicates () = ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormSymbol "?age" ] ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "name"; QueryFormSymbol "?name" ] ; QueryFormVector - [ QueryFormVector [ QueryFormSymbol ">"; QueryFormSymbol "?age"; QueryFormInt 18 ] ] + [ QueryFormVector [ QueryFormSymbol ">"; QueryFormSymbol "?age"; QueryFormInt 18L ] ] ] in assert_equal_query @@ -3545,8 +3545,8 @@ let test_parse_query_arithmetic_functions () = let db = empty_db () |> db_with - [ Add (Entity_id 1, "left", Int 2) - ; Add (Entity_id 1, "right", Int 5) + [ Add (Entity_id 1, "left", Int64 2L) + ; Add (Entity_id 1, "right", Int64 5L) ] in let query = @@ -3564,7 +3564,7 @@ let test_parse_query_arithmetic_functions () = in assert_equal_query "parse_query parses arithmetic function expressions" - [ [ Result_value (Int 7) ] ] + [ [ Result_value (Int64 7L) ] ] (q db (parse_query query)); let vector_call_query = QueryFormVector @@ -3582,7 +3582,7 @@ let test_parse_query_arithmetic_functions () = in assert_equal_query "parse_query parses vector-form arithmetic function calls" - [ [ Result_value (Int 7) ] ] + [ [ Result_value (Int64 7L) ] ] (q db (parse_query vector_call_query)) let test_parse_query_transaction_patterns () = @@ -3619,7 +3619,7 @@ let test_parse_query_transaction_patterns () = ; QueryFormSymbol "?op" ; QueryFormKeyword "where" ; QueryFormVector - [ QueryFormInt 1 + [ QueryFormInt 1L ; QueryFormKeyword "name" ; QueryFormString "Ivan" ; QueryFormSymbol "?tx" @@ -3646,9 +3646,9 @@ let test_parse_query_source_qualified_patterns () = empty_db () |> db_with [ Add (Entity_id 10, "email", String "ivan@example.com") - ; Add (Entity_id 10, "score", Int 7) + ; Add (Entity_id 10, "score", Int64 7L) ; Add (Entity_id 11, "email", String "olga@example.com") - ; Add (Entity_id 11, "score", Int 9) + ; Add (Entity_id 11, "score", Int64 9L) ] in let source_query = @@ -3668,7 +3668,7 @@ let test_parse_query_source_qualified_patterns () = in assert_equal_query "parse_query parses source-qualified database patterns" - [ [ Result_value (String "Ivan"); Result_value (Int 7) ] ] + [ [ Result_value (String "Ivan"); Result_value (Int64 7L) ] ] (q_sources names [ "scores", Db_source scores ] (parse_query source_query)); let source_call_query = QueryFormVector @@ -3685,18 +3685,18 @@ let test_parse_query_source_qualified_patterns () = ; QueryFormVector [ QueryFormSymbol "$scores"; QueryFormSymbol "?s"; QueryFormKeyword "score"; QueryFormSymbol "?score" ] ; QueryFormVector [ QueryFormSymbol "$scores" - ; QueryFormVector [ QueryFormSymbol ">"; QueryFormSymbol "?score"; QueryFormInt 6 ] + ; QueryFormVector [ QueryFormSymbol ">"; QueryFormSymbol "?score"; QueryFormInt 6L ] ] ; QueryFormVector [ QueryFormSymbol "$scores" - ; QueryFormVector [ QueryFormSymbol "+"; QueryFormSymbol "?score"; QueryFormInt 1 ] + ; QueryFormVector [ QueryFormSymbol "+"; QueryFormSymbol "?score"; QueryFormInt 1L ] ; QueryFormSymbol "?next" ] ] in assert_equal_query "parse_query parses source-qualified predicate and function clauses" - [ [ Result_value (String "Ivan"); Result_value (Int 8) ] ] + [ [ Result_value (String "Ivan"); Result_value (Int64 8L) ] ] (q_sources names [ "scores", Db_source scores ] (parse_query source_call_query)); assert_raises_invalid_arg "parse_query rejects undeclared sources on source-qualified predicates" @@ -3745,9 +3745,9 @@ let test_parse_query_find_pull_expressions () = empty_db () |> db_with [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 31) + ; Add (Entity_id 1, "age", Int64 31L) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 22) + ; Add (Entity_id 2, "age", Int64 22L) ] in let query = @@ -3799,7 +3799,7 @@ let test_parse_query_find_pull_expressions () = in assert_equal_query "parse_query supports dynamic pull find patterns" - [ [ Result_pull { pulled_id = 1; pulled_attrs = [ Keyword "age", Pulled_scalar (Int 31) ] } ] ] + [ [ Result_pull { pulled_id = 1; pulled_attrs = [ Keyword "age", Pulled_scalar (Int64 31L) ] } ] ] (q ~inputs:[ Arg_scalar (Result_value (List [ Keyword "age" ])) ] db @@ -3821,7 +3821,7 @@ let test_parse_query_find_pull_expressions () = in assert_equal_query "parse_query supports plain-symbol dynamic pull pattern inputs" - [ [ Result_pull { pulled_id = 1; pulled_attrs = [ Keyword "age", Pulled_scalar (Int 31) ] } ] ] + [ [ Result_pull { pulled_id = 1; pulled_attrs = [ Keyword "age", Pulled_scalar (Int64 31L) ] } ] ] (q ~inputs:[ Arg_scalar (Result_value (List [ Keyword "age" ])) ] db @@ -3895,11 +3895,11 @@ let test_parse_query_find_pull_expressions () = empty_db ~schema:[ "name", unique_identity ] () |> db_with [ Add (Entity_id 1, "name", String "Petr") - ; Add (Entity_id 1, "age", Int 44) + ; Add (Entity_id 1, "age", Int64 44L) ; Add (Entity_id 2, "name", String "Ivan") - ; Add (Entity_id 2, "age", Int 25) + ; Add (Entity_id 2, "age", Int64 25L) ; Add (Entity_id 3, "name", String "Oleg") - ; Add (Entity_id 3, "age", Int 11) + ; Add (Entity_id 3, "age", Int64 11L) ] in let lookup_ref_query = @@ -3917,23 +3917,23 @@ let test_parse_query_find_pull_expressions () = ; QueryFormVector [ QueryFormSymbol "?ref"; QueryFormSymbol "..." ] ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormSymbol "?ref"; QueryFormKeyword "age"; QueryFormSymbol "?age" ] - ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">="; QueryFormSymbol "?age"; QueryFormInt 18 ] ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">="; QueryFormSymbol "?age"; QueryFormInt 18L ] ] ] in assert_equal_query "parse_query resolves lookup-ref collection inputs in pull find expressions" [ [ Result_value (List [ Keyword "name"; String "Ivan" ]) - ; Result_value (Int 25) + ; Result_value (Int64 25L) ; Result_pull { pulled_id = 2 - ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2); kw "name", Pulled_scalar (String "Ivan") ] + ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L); kw "name", Pulled_scalar (String "Ivan") ] } ] ; [ Result_value (List [ Keyword "name"; String "Petr" ]) - ; Result_value (Int 44) + ; Result_value (Int64 44L) ; Result_pull { pulled_id = 1 - ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 1); kw "name", Pulled_scalar (String "Petr") ] + ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 1L); kw "name", Pulled_scalar (String "Petr") ] } ] ] @@ -3953,7 +3953,7 @@ let test_parse_query_missing_and_get_else_clauses () = empty_db () |> db_with [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "height", Int 180) + ; Add (Entity_id 1, "height", Int64 180L) ; Add (Entity_id 2, "name", String "Petr") ] in @@ -3996,7 +3996,7 @@ let test_parse_query_missing_and_get_else_clauses () = in assert_equal_query "parse_query parses get-else clauses" - [ [ Result_value (String "Ivan"); Result_value (Int 180) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 180L) ] ; [ Result_value (String "Petr"); Result_value (String "Unknown") ] ] (q db (parse_query get_else_query)); @@ -4008,7 +4008,7 @@ let test_parse_query_missing_and_get_else_clauses () = ; QueryFormVector [ QueryFormList [ QueryFormSymbol "get-else" - ; QueryFormInt 2 + ; QueryFormInt 2L ; QueryFormKeyword "height" ; QueryFormNil ] @@ -4024,7 +4024,7 @@ let test_parse_query_missing_and_get_else_clauses () = |> db_with [ Add (Entity_id 1, "name", String "Ivan") ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "height", Int 175) + ; Add (Entity_id 2, "height", Int64 175L) ] in let source_query = @@ -4060,7 +4060,7 @@ let test_parse_query_missing_and_get_else_clauses () = assert_equal_query "parse_query parses source-qualified missing? and get-else clauses" [ [ Result_value (String "Ivan"); Result_value (String "Unknown") ] - ; [ Result_value (String "Petr"); Result_value (Int 175) ] + ; [ Result_value (String "Petr"); Result_value (Int64 175L) ] ] (q_sources db [ "people", Db_source people ] (parse_query source_query)) @@ -4069,10 +4069,10 @@ let test_parse_query_get_some_and_get_clauses () = empty_db () |> db_with [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 15) + ; Add (Entity_id 1, "age", Int64 15L) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 22) - ; Add (Entity_id 2, "height", Int 240) + ; Add (Entity_id 2, "age", Int64 22L) + ; Add (Entity_id 2, "height", Int64 240L) ] in let get_some_query = @@ -4097,13 +4097,13 @@ let test_parse_query_get_some_and_get_clauses () = in assert_equal_query "parse_query parses get-some clauses with tuple outputs" - [ [ Result_entity 1; Result_attr "age"; Result_value (Int 15) ] - ; [ Result_entity 2; Result_attr "height"; Result_value (Int 240) ] + [ [ Result_entity 1; Result_attr "age"; Result_value (Int64 15L) ] + ; [ Result_entity 2; Result_attr "height"; Result_value (Int64 240L) ] ] (q db (parse_query get_some_query)); let source_db = empty_db () - |> db_with [ Add (Entity_id 10, "name", String "Oleg"); Add (Entity_id 10, "age", Int 37) ] + |> db_with [ Add (Entity_id 10, "name", String "Oleg"); Add (Entity_id 10, "age", Int64 37L) ] in let source_get_some_query = QueryFormVector @@ -4129,7 +4129,7 @@ let test_parse_query_get_some_and_get_clauses () = in assert_equal_query "parse_query parses source-qualified get-some clauses" - [ [ Result_attr "age"; Result_value (Int 37) ] ] + [ [ Result_attr "age"; Result_value (Int64 37L) ] ] (q_sources db [ "people", Db_source source_db ] (parse_query source_get_some_query)); let get_query = QueryFormVector @@ -4139,7 +4139,7 @@ let test_parse_query_get_some_and_get_clauses () = ; QueryFormVector [ QueryFormList [ QueryFormSymbol "get" - ; QueryFormMap [ QueryFormKeyword "a", QueryFormInt 1; QueryFormKeyword "b", QueryFormInt 2 ] + ; QueryFormMap [ QueryFormKeyword "a", QueryFormInt 1L; QueryFormKeyword "b", QueryFormInt 2L ] ; QueryFormKeyword "b" ] ; QueryFormSymbol "?value" @@ -4148,7 +4148,7 @@ let test_parse_query_get_some_and_get_clauses () = in assert_equal_query "parse_query parses get clauses" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q db (parse_query get_query)); assert_raises_invalid_arg "parse_query rejects get-some without attributes" @@ -4191,8 +4191,8 @@ let test_parse_query_collection_value_clauses () = in assert_equal_query "parse_query parses count clauses" - [ [ Result_value (String "empty"); Result_value (Int 0) ] - ; [ Result_value (String "full"); Result_value (Int 2) ] + [ [ Result_value (String "empty"); Result_value (Int64 0L) ] + ; [ Result_value (String "full"); Result_value (Int64 2L) ] ] (q db (parse_query count_query)); let empty_query = @@ -4230,7 +4230,7 @@ let test_parse_query_collection_value_clauses () = ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "label"; QueryFormSymbol "?label" ] ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "items"; QueryFormSymbol "?items" ] - ; QueryFormVector [ QueryFormList [ QueryFormSymbol "contains?"; QueryFormSymbol "?items"; QueryFormInt 1 ] ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol "contains?"; QueryFormSymbol "?items"; QueryFormInt 1L ] ] ] in assert_equal_query @@ -4246,7 +4246,7 @@ let test_parse_query_collection_value_clauses () = ; QueryFormVector [ QueryFormList [ QueryFormSymbol "get" - ; QueryFormMap [ QueryFormKeyword "answer", QueryFormInt 42 ] + ; QueryFormMap [ QueryFormKeyword "answer", QueryFormInt 42L ] ; QueryFormKeyword "answer" ; QueryFormString "missing" ] @@ -4255,7 +4255,7 @@ let test_parse_query_collection_value_clauses () = ; QueryFormVector [ QueryFormList [ QueryFormSymbol "get" - ; QueryFormMap [ QueryFormKeyword "answer", QueryFormInt 42 ] + ; QueryFormMap [ QueryFormKeyword "answer", QueryFormInt 42L ] ; QueryFormKeyword "missing" ; QueryFormString "fallback" ] @@ -4265,7 +4265,7 @@ let test_parse_query_collection_value_clauses () = in assert_equal_query "parse_query parses get default clauses" - [ [ Result_value (Int 42); Result_value (String "fallback") ] ] + [ [ Result_value (Int64 42L); Result_value (String "fallback") ] ] (q db (parse_query get_default_query)) let test_parse_query_type_and_numeric_predicates () = @@ -4277,7 +4277,7 @@ let test_parse_query_type_and_numeric_predicates () = ; Add (Entity_id 2, "label", String "float") ; Add (Entity_id 2, "value", Float 2.5) ; Add (Entity_id 3, "label", String "int") - ; Add (Entity_id 3, "value", Int 1) + ; Add (Entity_id 3, "value", Int64 1L) ; Add (Entity_id 4, "label", String "keyword") ; Add (Entity_id 4, "value", Keyword "user/name") ; Add (Entity_id 5, "label", String "string") @@ -4322,13 +4322,13 @@ let test_parse_query_type_and_numeric_predicates () = ; Add (Entity_id 2, "label", String "float-zero") ; Add (Entity_id 2, "value", Float 0.0) ; Add (Entity_id 3, "label", String "negative") - ; Add (Entity_id 3, "value", Int (-2)) + ; Add (Entity_id 3, "value", Int64 (-2L)) ; Add (Entity_id 4, "label", String "odd-negative") - ; Add (Entity_id 4, "value", Int (-1)) + ; Add (Entity_id 4, "value", Int64 (-1L)) ; Add (Entity_id 5, "label", String "positive") - ; Add (Entity_id 5, "value", Int 3) + ; Add (Entity_id 5, "value", Int64 3L) ; Add (Entity_id 6, "label", String "zero") - ; Add (Entity_id 6, "value", Int 0) + ; Add (Entity_id 6, "value", Int64 0L) ; Add (Entity_id 7, "label", String "string") ; Add (Entity_id 7, "value", String "0") ] @@ -4366,7 +4366,7 @@ let test_parse_query_type_and_numeric_predicates () = [ QueryFormList [ QueryFormSymbol "number?" ; QueryFormSymbol "?value" - ; QueryFormInt 1 + ; QueryFormInt 1L ] ] ]))) @@ -4376,17 +4376,17 @@ let test_parse_query_variadic_comparison_predicates () = empty_db () |> db_with [ Add (Entity_id 1, "label", String "ascending") - ; Add (Entity_id 1, "x", Int 1) - ; Add (Entity_id 1, "y", Int 2) - ; Add (Entity_id 1, "z", Int 3) + ; Add (Entity_id 1, "x", Int64 1L) + ; Add (Entity_id 1, "y", Int64 2L) + ; Add (Entity_id 1, "z", Int64 3L) ; Add (Entity_id 2, "label", String "descending") - ; Add (Entity_id 2, "x", Int 3) - ; Add (Entity_id 2, "y", Int 2) - ; Add (Entity_id 2, "z", Int 1) + ; Add (Entity_id 2, "x", Int64 3L) + ; Add (Entity_id 2, "y", Int64 2L) + ; Add (Entity_id 2, "z", Int64 1L) ; Add (Entity_id 3, "label", String "equal") - ; Add (Entity_id 3, "x", Int 2) - ; Add (Entity_id 3, "y", Int 2) - ; Add (Entity_id 3, "z", Int 2) + ; Add (Entity_id 3, "x", Int64 2L) + ; Add (Entity_id 3, "y", Int64 2L) + ; Add (Entity_id 3, "z", Int64 2L) ] in let labels_with_predicate predicate args = @@ -4432,7 +4432,7 @@ let test_parse_query_boolean_predicates () = [ Add (Entity_id 1, "label", String "false") ; Add (Entity_id 1, "value", Bool false) ; Add (Entity_id 2, "label", String "int") - ; Add (Entity_id 2, "value", Int 1) + ; Add (Entity_id 2, "value", Int64 1L) ; Add (Entity_id 3, "label", String "nil") ; Add (Entity_id 4, "label", String "true") ; Add (Entity_id 4, "value", Bool true) @@ -4546,7 +4546,7 @@ let test_parse_query_boolean_predicates () = ; QueryFormSymbol "?int-not" ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormList [ QueryFormSymbol "not"; QueryFormNil ]; QueryFormSymbol "?nil-not" ] - ; QueryFormVector [ QueryFormList [ QueryFormSymbol "not"; QueryFormInt 1 ]; QueryFormSymbol "?int-not" ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol "not"; QueryFormInt 1L ]; QueryFormSymbol "?int-not" ] ] in assert_equal_query @@ -4640,15 +4640,15 @@ let test_parse_query_core_value_functions () = ; QueryFormSymbol "?or" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "compare"; QueryFormInt 1; QueryFormInt 2 ] + [ QueryFormList [ QueryFormSymbol "compare"; QueryFormInt 1L; QueryFormInt 2L ] ; QueryFormSymbol "?compare" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "min"; QueryFormInt 3; QueryFormInt 1; QueryFormInt 2 ] + [ QueryFormList [ QueryFormSymbol "min"; QueryFormInt 3L; QueryFormInt 1L; QueryFormInt 2L ] ; QueryFormSymbol "?min" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "max"; QueryFormInt 3; QueryFormInt 1; QueryFormInt 2 ] + [ QueryFormList [ QueryFormSymbol "max"; QueryFormInt 3L; QueryFormInt 1L; QueryFormInt 2L ] ; QueryFormSymbol "?max" ] ] @@ -4658,9 +4658,9 @@ let test_parse_query_core_value_functions () = [ [ Result_value (Keyword "user/name") ; Result_value (Bool false) ; Result_value (Keyword "user/name") - ; Result_value (Int (-1)) - ; Result_value (Int 1) - ; Result_value (Int 3) + ; Result_value (Int64 (-1L)) + ; Result_value (Int64 1L) + ; Result_value (Int64 3L) ] ] (q (empty_db ()) (parse_query query)); @@ -4674,7 +4674,7 @@ let test_parse_query_core_value_functions () = ; QueryFormSymbol "?compare" ; QueryFormKeyword "where" ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "compare"; QueryFormInt 1 ] + [ QueryFormList [ QueryFormSymbol "compare"; QueryFormInt 1L ] ; QueryFormSymbol "?compare" ] ]))) @@ -4688,29 +4688,29 @@ let test_parse_query_random_and_identity_predicates () = ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormList [ QueryFormSymbol "rand" ]; QueryFormSymbol "?rand" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "rand-int"; QueryFormInt 10 ] + [ QueryFormList [ QueryFormSymbol "rand-int"; QueryFormInt 10L ] ; QueryFormSymbol "?rand_int" ] ] in (match q (empty_db ()) (parse_query random_query) with - | [ [ Result_value (Float rand); Result_value (Int rand_int) ] ] -> + | [ [ Result_value (Float rand); Result_value (Int64 rand_int) ] ] -> if rand < 0.0 || rand >= 1.0 then failwith "parse_query rand should be in [0, 1)"; - if rand_int < 0 || rand_int >= 10 then failwith "parse_query rand-int should be in [0, n)" + if rand_int < 0L || rand_int >= 10L then failwith "parse_query rand-int should be in [0, n)" | _ -> failwith "parse_query random functions should produce one row"); let db = empty_db () |> db_with [ Add (Entity_id 1, "label", String "different") - ; Add (Entity_id 1, "a", Int 1) - ; Add (Entity_id 1, "b", Int 2) - ; Add (Entity_id 1, "c", Int 1) - ; Add (Entity_id 1, "d", Int 3) + ; Add (Entity_id 1, "a", Int64 1L) + ; Add (Entity_id 1, "b", Int64 2L) + ; Add (Entity_id 1, "c", Int64 1L) + ; Add (Entity_id 1, "d", Int64 3L) ; Add (Entity_id 2, "label", String "same") - ; Add (Entity_id 2, "a", Int 1) - ; Add (Entity_id 2, "b", Int 2) + ; Add (Entity_id 2, "a", Int64 1L) + ; Add (Entity_id 2, "b", Int64 2L) ; Add (Entity_id 2, "c", Float 1.0) - ; Add (Entity_id 2, "d", Int 2) + ; Add (Entity_id 2, "d", Int64 2L) ] in let base_where = @@ -4959,7 +4959,7 @@ let test_parse_query_string_trim_index_and_subs () = in assert_equal_query "parse_query parses clojure.string index functions" - [ [ Result_value (Int 2); Result_value (Int 4) ] ] + [ [ Result_value (Int64 2L); Result_value (Int64 4L) ] ] (q (empty_db ()) (parse_query index_query)); let subs_query = QueryFormVector @@ -4968,11 +4968,11 @@ let test_parse_query_string_trim_index_and_subs () = ; QueryFormSymbol "?suffix" ; QueryFormKeyword "where" ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "subs"; QueryFormString "datascript"; QueryFormInt 4; QueryFormInt 10 ] + [ QueryFormList [ QueryFormSymbol "subs"; QueryFormString "datascript"; QueryFormInt 4L; QueryFormInt 10L ] ; QueryFormSymbol "?part" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "subs"; QueryFormString "datascript"; QueryFormInt 4 ] + [ QueryFormList [ QueryFormSymbol "subs"; QueryFormString "datascript"; QueryFormInt 4L ] ; QueryFormSymbol "?suffix" ] ] @@ -5012,7 +5012,7 @@ let test_parse_query_string_build_replace_regex_and_split () = [ QueryFormList [ QueryFormSymbol "str" ; QueryFormString "score=" - ; QueryFormInt 42 + ; QueryFormInt 42L ; QueryFormBool true ] ; QueryFormSymbol "?built" @@ -5144,7 +5144,7 @@ let test_parse_query_string_build_replace_regex_and_split () = [ QueryFormSymbol "clojure.string/split" ; QueryFormString "red,green;blue" ; QueryFormSymbol "?separator" - ; QueryFormInt 2 + ; QueryFormInt 2L ] ; QueryFormSymbol "?limited-parts" ] @@ -5219,39 +5219,39 @@ let test_parse_query_collection_constructors () = ; QueryFormSymbol "?tuple" ; QueryFormKeyword "where" ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "vector"; QueryFormKeyword "db/add"; QueryFormInt (-1); QueryFormKeyword "attr"; QueryFormInt 12 ] + [ QueryFormList [ QueryFormSymbol "vector"; QueryFormKeyword "db/add"; QueryFormInt (-1L); QueryFormKeyword "attr"; QueryFormInt 12L ] ; QueryFormSymbol "?vector" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "list"; QueryFormInt 2; QueryFormInt 1; QueryFormInt 1 ] + [ QueryFormList [ QueryFormSymbol "list"; QueryFormInt 2L; QueryFormInt 1L; QueryFormInt 1L ] ; QueryFormSymbol "?list" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "set"; QueryFormInt 2; QueryFormInt 1; QueryFormInt 1 ] + [ QueryFormList [ QueryFormSymbol "set"; QueryFormInt 2L; QueryFormInt 1L; QueryFormInt 1L ] ; QueryFormSymbol "?set" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "hash-map"; QueryFormKeyword "left"; QueryFormInt 1; QueryFormKeyword "right"; QueryFormInt 2 ] + [ QueryFormList [ QueryFormSymbol "hash-map"; QueryFormKeyword "left"; QueryFormInt 1L; QueryFormKeyword "right"; QueryFormInt 2L ] ; QueryFormSymbol "?hash_map" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "array-map"; QueryFormKeyword "right"; QueryFormInt 2; QueryFormKeyword "left"; QueryFormInt 1 ] + [ QueryFormList [ QueryFormSymbol "array-map"; QueryFormKeyword "right"; QueryFormInt 2L; QueryFormKeyword "left"; QueryFormInt 1L ] ; QueryFormSymbol "?array_map" ] ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "tuple"; QueryFormInt 1; QueryFormInt 2 ] + [ QueryFormList [ QueryFormSymbol "tuple"; QueryFormInt 1L; QueryFormInt 2L ] ; QueryFormSymbol "?tuple" ] ] in assert_equal_query "parse_query parses collection constructor functions" - [ [ Result_value (Vector [ Keyword "db/add"; Int (-1); Keyword "attr"; Int 12 ]) - ; Result_value (List [ Int 2; Int 1; Int 1 ]) - ; Result_value (Set [ Int 1; Int 2 ]) - ; Result_value (Map [ Keyword "left", Int 1; Keyword "right", Int 2 ]) - ; Result_value (Map [ Keyword "left", Int 1; Keyword "right", Int 2 ]) - ; Result_value (Tuple [ Some (Int 1); Some (Int 2) ]) + [ [ Result_value (Vector [ Keyword "db/add"; Int64 (-1L); Keyword "attr"; Int64 12L ]) + ; Result_value (List [ Int64 2L; Int64 1L; Int64 1L ]) + ; Result_value (Set [ Int64 1L; Int64 2L ]) + ; Result_value (Map [ Keyword "left", Int64 1L; Keyword "right", Int64 2L ]) + ; Result_value (Map [ Keyword "left", Int64 1L; Keyword "right", Int64 2L ]) + ; Result_value (Tuple [ Some (Int64 1L); Some (Int64 2L) ]) ] ] (q (empty_db ()) (parse_query collection_query)); @@ -5260,12 +5260,12 @@ let test_parse_query_collection_constructors () = [ QueryFormKeyword "find" ; QueryFormSymbol "?x" ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormList [ QueryFormSymbol "range"; QueryFormInt 1; QueryFormInt 8; QueryFormInt 3 ]; QueryFormSymbol "?x" ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol "range"; QueryFormInt 1L; QueryFormInt 8L; QueryFormInt 3L ]; QueryFormSymbol "?x" ] ] in assert_equal_query "parse_query parses range functions" - [ [ Result_value (Int 1) ]; [ Result_value (Int 4) ]; [ Result_value (Int 7) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 4L) ]; [ Result_value (Int64 7L) ] ] (q (empty_db ()) (parse_query range_query)); let untuple_query = QueryFormVector @@ -5296,7 +5296,7 @@ let test_parse_query_collection_constructors () = ; QueryFormSymbol "?m" ; QueryFormKeyword "where" ; QueryFormVector - [ QueryFormList [ QueryFormSymbol "hash-map"; QueryFormKeyword "left"; QueryFormInt 1; QueryFormKeyword "right" ] + [ QueryFormList [ QueryFormSymbol "hash-map"; QueryFormKeyword "left"; QueryFormInt 1L; QueryFormKeyword "right" ] ; QueryFormSymbol "?m" ] ]))) @@ -5481,11 +5481,11 @@ let test_parse_query_aggregate_find_expressions () = empty_db () |> db_with [ Add (Entity_id 1, "color", String "red") - ; Add (Entity_id 1, "heads", Int 3) + ; Add (Entity_id 1, "heads", Int64 3L) ; Add (Entity_id 2, "color", String "red") - ; Add (Entity_id 2, "heads", Int 1) + ; Add (Entity_id 2, "heads", Int64 1L) ; Add (Entity_id 3, "color", String "blue") - ; Add (Entity_id 3, "heads", Int 2) + ; Add (Entity_id 3, "heads", Int64 2L) ] in let query = @@ -5505,18 +5505,18 @@ let test_parse_query_aggregate_find_expressions () = assert_equal_query "parse_query parses aggregate find expressions" [ [ Result_value (String "blue") - ; Result_value (Int 2) - ; Result_value (Int 2) - ; Result_value (Int 2) - ; Result_value (Int 1) - ; Result_value (Int 1) + ; Result_value (Int64 2L) + ; Result_value (Int64 2L) + ; Result_value (Int64 2L) + ; Result_value (Int64 1L) + ; Result_value (Int64 1L) ] ; [ Result_value (String "red") - ; Result_value (Int 4) - ; Result_value (Int 1) - ; Result_value (Int 3) - ; Result_value (Int 2) - ; Result_value (Int 2) + ; Result_value (Int64 4L) + ; Result_value (Int64 1L) + ; Result_value (Int64 3L) + ; Result_value (Int64 2L) + ; Result_value (Int64 2L) ] ] (q db (parse_query query)); @@ -5533,8 +5533,8 @@ let test_parse_query_aggregate_find_expressions () = in assert_equal_query "parse_query parses vector-form aggregate find expressions" - [ [ Result_value (String "blue"); Result_value (Int 2); Result_value (Int 1) ] - ; [ Result_value (String "red"); Result_value (Int 4); Result_value (Int 2) ] + [ [ Result_value (String "blue"); Result_value (Int64 2L); Result_value (Int64 1L) ] + ; [ Result_value (String "red"); Result_value (Int64 4L); Result_value (Int64 2L) ] ] (q db (parse_query vector_query)); assert_raises_invalid_arg @@ -5554,25 +5554,25 @@ let test_parse_query_extended_aggregate_find_expressions () = empty_db () |> db_with [ Add (Entity_id 1, "color", String "red") - ; Add (Entity_id 1, "amount", Int 1) + ; Add (Entity_id 1, "amount", Int64 1L) ; Add (Entity_id 2, "color", String "red") - ; Add (Entity_id 2, "amount", Int 2) + ; Add (Entity_id 2, "amount", Int64 2L) ; Add (Entity_id 3, "color", String "red") - ; Add (Entity_id 3, "amount", Int 3) + ; Add (Entity_id 3, "amount", Int64 3L) ; Add (Entity_id 4, "color", String "red") - ; Add (Entity_id 4, "amount", Int 4) + ; Add (Entity_id 4, "amount", Int64 4L) ; Add (Entity_id 5, "color", String "blue") - ; Add (Entity_id 5, "amount", Int 7) + ; Add (Entity_id 5, "amount", Int64 7L) ; Add (Entity_id 6, "color", String "blue") - ; Add (Entity_id 6, "amount", Int 8) + ; Add (Entity_id 6, "amount", Int64 8L) ] in let min_max_n_query = QueryFormVector [ QueryFormKeyword "find" ; QueryFormSymbol "?color" - ; QueryFormList [ QueryFormSymbol "max"; QueryFormInt 3; QueryFormSymbol "?amount" ] - ; QueryFormList [ QueryFormSymbol "min"; QueryFormInt 3; QueryFormSymbol "?amount" ] + ; QueryFormList [ QueryFormSymbol "max"; QueryFormInt 3L; QueryFormSymbol "?amount" ] + ; QueryFormList [ QueryFormSymbol "min"; QueryFormInt 3L; QueryFormSymbol "?amount" ] ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "color"; QueryFormSymbol "?color" ] ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "amount"; QueryFormSymbol "?amount" ] @@ -5581,23 +5581,23 @@ let test_parse_query_extended_aggregate_find_expressions () = assert_equal_query "parse_query parses min/max n aggregate find expressions" [ [ Result_value (String "blue") - ; Result_value (Tuple [ Some (Int 7); Some (Int 8) ]) - ; Result_value (Tuple [ Some (Int 7); Some (Int 8) ]) + ; Result_value (Tuple [ Some (Int64 7L); Some (Int64 8L) ]) + ; Result_value (Tuple [ Some (Int64 7L); Some (Int64 8L) ]) ] ; [ Result_value (String "red") - ; Result_value (Tuple [ Some (Int 2); Some (Int 3); Some (Int 4) ]) - ; Result_value (Tuple [ Some (Int 1); Some (Int 2); Some (Int 3) ]) + ; Result_value (Tuple [ Some (Int64 2L); Some (Int64 3L); Some (Int64 4L) ]) + ; Result_value (Tuple [ Some (Int64 1L); Some (Int64 2L); Some (Int64 3L) ]) ] ] (q db (parse_query min_max_n_query)); let stats_db = empty_db () |> db_with - [ Add (Entity_id 1, "sample", Int 10) - ; Add (Entity_id 2, "sample", Int 15) - ; Add (Entity_id 3, "sample", Int 20) - ; Add (Entity_id 4, "sample", Int 35) - ; Add (Entity_id 5, "sample", Int 75) + [ Add (Entity_id 1, "sample", Int64 10L) + ; Add (Entity_id 2, "sample", Int64 15L) + ; Add (Entity_id 3, "sample", Int64 20L) + ; Add (Entity_id 4, "sample", Int64 35L) + ; Add (Entity_id 5, "sample", Int64 75L) ] in let stats_query = @@ -5632,8 +5632,8 @@ let test_parse_query_extended_aggregate_find_expressions () = in assert_equal_query "parse_query parses distinct aggregate find expressions" - [ [ Result_value (String "blue"); Result_value (Set [ Int 7; Int 8 ]) ] - ; [ Result_value (String "red"); Result_value (Set [ Int 1; Int 2; Int 3; Int 4 ]) ] + [ [ Result_value (String "blue"); Result_value (Set [ Int64 7L; Int64 8L ]) ] + ; [ Result_value (String "red"); Result_value (Set [ Int64 1L; Int64 2L; Int64 3L; Int64 4L ]) ] ] (q db (parse_query distinct_query)); let parameterized_min_max_query = @@ -5651,26 +5651,26 @@ let test_parse_query_extended_aggregate_find_expressions () = assert_equal_query "parse_query parses aggregate parameter passing" [ [ Result_value (String "blue") - ; Result_value (Tuple [ Some (Int 7); Some (Int 8) ]) - ; Result_value (Tuple [ Some (Int 7); Some (Int 8) ]) + ; Result_value (Tuple [ Some (Int64 7L); Some (Int64 8L) ]) + ; Result_value (Tuple [ Some (Int64 7L); Some (Int64 8L) ]) ] ; [ Result_value (String "red") - ; Result_value (Tuple [ Some (Int 3); Some (Int 4); Some (Int 5) ]) - ; Result_value (Tuple [ Some (Int 1); Some (Int 2); Some (Int 3) ]) + ; Result_value (Tuple [ Some (Int64 3L); Some (Int64 4L); Some (Int64 5L) ]) + ; Result_value (Tuple [ Some (Int64 1L); Some (Int64 2L); Some (Int64 3L) ]) ] ] (q ~inputs: [ Arg_relation - [ [ Result_value (String "red"); Result_value (Int 1) ] - ; [ Result_value (String "red"); Result_value (Int 2) ] - ; [ Result_value (String "red"); Result_value (Int 3) ] - ; [ Result_value (String "red"); Result_value (Int 4) ] - ; [ Result_value (String "red"); Result_value (Int 5) ] - ; [ Result_value (String "blue"); Result_value (Int 7) ] - ; [ Result_value (String "blue"); Result_value (Int 8) ] + [ [ Result_value (String "red"); Result_value (Int64 1L) ] + ; [ Result_value (String "red"); Result_value (Int64 2L) ] + ; [ Result_value (String "red"); Result_value (Int64 3L) ] + ; [ Result_value (String "red"); Result_value (Int64 4L) ] + ; [ Result_value (String "red"); Result_value (Int64 5L) ] + ; [ Result_value (String "blue"); Result_value (Int64 7L) ] + ; [ Result_value (String "blue"); Result_value (Int64 8L) ] ] - ; Arg_scalar (Result_value (Int 3)) + ; Arg_scalar (Result_value (Int64 3L)) ] (empty_db ()) (parse_query parameterized_min_max_query)); @@ -5678,8 +5678,8 @@ let test_parse_query_extended_aggregate_find_expressions () = QueryFormVector [ QueryFormKeyword "find" ; QueryFormList [ QueryFormSymbol "rand"; QueryFormSymbol "?x" ] - ; QueryFormList [ QueryFormSymbol "rand"; QueryFormInt 5; QueryFormSymbol "?x" ] - ; QueryFormList [ QueryFormSymbol "sample"; QueryFormInt 2; QueryFormSymbol "?x" ] + ; QueryFormList [ QueryFormSymbol "rand"; QueryFormInt 5L; QueryFormSymbol "?x" ] + ; QueryFormList [ QueryFormSymbol "sample"; QueryFormInt 2L; QueryFormSymbol "?x" ] ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "x"; QueryFormSymbol "?x" ] ] @@ -5687,14 +5687,14 @@ let test_parse_query_extended_aggregate_find_expressions () = let random_db = empty_db () |> db_with - [ Add (Entity_id 1, "x", Int 1) - ; Add (Entity_id 2, "x", Int 2) - ; Add (Entity_id 3, "x", Int 3) + [ Add (Entity_id 1, "x", Int64 1L) + ; Add (Entity_id 2, "x", Int64 2L) + ; Add (Entity_id 3, "x", Int64 3L) ] in (match q random_db (parse_query random_query) with | [ [ Result_value rand_value; Result_value (Tuple rand_values); Result_value (Tuple sample_values) ] ] -> - let values = [ Int 1; Int 2; Int 3 ] in + let values = [ Int64 1L; Int64 2L; Int64 3L ] in let member value = List.mem value values in if not (member rand_value) then failwith "parse_query rand aggregate returned a value outside the input"; let rand_values = List.map Option.get rand_values in @@ -5713,7 +5713,7 @@ let test_parse_query_extended_aggregate_find_expressions () = [ QueryFormKeyword "find" ; QueryFormList [ QueryFormSymbol "min"; QueryFormString "n"; QueryFormSymbol "?x" ] ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormList [ QueryFormSymbol "ground"; QueryFormVector [ QueryFormInt 1 ] ]; QueryFormSymbol "?x" ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol "ground"; QueryFormVector [ QueryFormInt 1L ] ]; QueryFormSymbol "?x" ] ]))) let test_parse_query_not_and_not_join_clauses () = @@ -5771,9 +5771,9 @@ let test_parse_query_not_and_not_join_clauses () = let releases_db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "artist", One_value (String "A"); "year", One_value (Int 1970) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "artist", One_value (String "A"); "year", One_value (Int 1971) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "artist", One_value (String "B"); "year", One_value (Int 1971) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "artist", One_value (String "A"); "year", One_value (Int64 1970L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "artist", One_value (String "A"); "year", One_value (Int64 1971L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "artist", One_value (String "B"); "year", One_value (Int64 1971L) ] } ] in let not_join_query = @@ -5786,7 +5786,7 @@ let test_parse_query_not_and_not_join_clauses () = ; QueryFormVector [ QueryFormSymbol "not-join" ; QueryFormVector [ QueryFormSymbol "?artist" ] - ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1970 ] + ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1970L ] ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "artist"; QueryFormSymbol "?artist" ] ] ] @@ -5840,11 +5840,11 @@ let test_parse_query_or_and_or_join_clauses () = empty_db () |> db_with [ Add (Entity_id 1, "artist", String "A") - ; Add (Entity_id 1, "year", Int 1970) + ; Add (Entity_id 1, "year", Int64 1970L) ; Add (Entity_id 2, "artist", String "A") - ; Add (Entity_id 2, "year", Int 1971) + ; Add (Entity_id 2, "year", Int64 1971L) ; Add (Entity_id 3, "artist", String "B") - ; Add (Entity_id 3, "year", Int 1971) + ; Add (Entity_id 3, "year", Int64 1971L) ] in let or_join_query = @@ -5858,12 +5858,12 @@ let test_parse_query_or_and_or_join_clauses () = ; QueryFormVector [ QueryFormSymbol "?artist" ] ; QueryFormVector [ QueryFormSymbol "and" - ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1970 ] + ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1970L ] ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "artist"; QueryFormSymbol "?artist" ] ] ; QueryFormVector [ QueryFormSymbol "and" - ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1972 ] + ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1972L ] ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "artist"; QueryFormSymbol "?artist" ] ] ] @@ -5884,12 +5884,12 @@ let test_parse_query_or_and_or_join_clauses () = ; QueryFormVector [ QueryFormSymbol "?artist" ] ; QueryFormList [ QueryFormSymbol "and" - ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1970 ] + ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1970L ] ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "artist"; QueryFormSymbol "?artist" ] ] ; QueryFormList [ QueryFormSymbol "and" - ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1972 ] + ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "year"; QueryFormInt 1972L ] ; QueryFormVector [ QueryFormSymbol "?release"; QueryFormKeyword "artist"; QueryFormSymbol "?artist" ] ] ] @@ -6245,9 +6245,9 @@ let test_parse_query_source_qualified_composite_clauses () = let ages = empty_db () |> db_with - [ Add (Entity_id 1, "age", Int 10) - ; Add (Entity_id 2, "age", Int 20) - ; Add (Entity_id 3, "score", Int 1) + [ Add (Entity_id 1, "age", Int64 10L) + ; Add (Entity_id 2, "age", Int64 20L) + ; Add (Entity_id 3, "score", Int64 1L) ] in let sources = [ "names", Db_source names; "ages", Db_source ages ] in @@ -6265,7 +6265,7 @@ let test_parse_query_source_qualified_composite_clauses () = [ QueryFormSymbol "$ages" ; QueryFormVector [ QueryFormSymbol "not" - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] ] ] ] @@ -6289,7 +6289,7 @@ let test_parse_query_source_qualified_composite_clauses () = ; QueryFormVector [ QueryFormSymbol "not-join" ; QueryFormVector [ QueryFormSymbol "?e" ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] ] ] ] @@ -6312,8 +6312,8 @@ let test_parse_query_source_qualified_composite_clauses () = [ QueryFormSymbol "$ages" ; QueryFormVector [ QueryFormSymbol "or" - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20L ] ] ] ] @@ -6337,8 +6337,8 @@ let test_parse_query_source_qualified_composite_clauses () = ; QueryFormVector [ QueryFormSymbol "or-join" ; QueryFormVector [ QueryFormSymbol "?e" ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20L ] ] ] ] @@ -6360,7 +6360,7 @@ let test_parse_query_source_qualified_composite_clauses () = ; QueryFormList [ QueryFormSymbol "$ages" ; QueryFormSymbol "not" - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] ] ] in @@ -6382,7 +6382,7 @@ let test_parse_query_source_qualified_composite_clauses () = [ QueryFormSymbol "$ages" ; QueryFormSymbol "not-join" ; QueryFormVector [ QueryFormSymbol "?e" ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] ] ] in @@ -6403,8 +6403,8 @@ let test_parse_query_source_qualified_composite_clauses () = ; QueryFormList [ QueryFormSymbol "$ages" ; QueryFormSymbol "or" - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20L ] ] ] in @@ -6426,8 +6426,8 @@ let test_parse_query_source_qualified_composite_clauses () = [ QueryFormSymbol "$ages" ; QueryFormSymbol "or-join" ; QueryFormVector [ QueryFormSymbol "?e" ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10 ] - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 10L ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 20L ] ] ] in @@ -6454,15 +6454,15 @@ let test_parse_query_in_bindings () = [ Add (Entity_id 1, "name", String "Ivan") ; Add (Entity_id 1, "first", String "Ivan") ; Add (Entity_id 1, "last", String "Petrov") - ; Add (Entity_id 1, "age", Int 31) + ; Add (Entity_id 1, "age", Int64 31L) ; Add (Entity_id 2, "name", String "Petr") ; Add (Entity_id 2, "first", String "Petr") ; Add (Entity_id 2, "last", String "Ivanov") - ; Add (Entity_id 2, "age", Int 25) + ; Add (Entity_id 2, "age", Int64 25L) ; Add (Entity_id 3, "name", String "Oleg") ; Add (Entity_id 3, "first", String "Oleg") ; Add (Entity_id 3, "last", String "Petrov") - ; Add (Entity_id 3, "age", Int 44) + ; Add (Entity_id 3, "age", Int64 44L) ] in let scalar_query = @@ -6493,7 +6493,7 @@ let test_parse_query_in_bindings () = in assert_equal_query "parse_query parses entity-ref :in arguments" - [ [ Result_value (Int 31) ] ] + [ [ Result_value (Int64 31L) ] ] (q ~inputs:[ Arg_entity_ref (Lookup_ref ("name", String "Ivan")) ] db (parse_query entity_ref_query)); let collection_query = QueryFormVector @@ -6725,18 +6725,18 @@ let test_parse_query_in_bindings () = ; QueryFormSymbol "..." ] ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">"; QueryFormSymbol "?v"; QueryFormInt 1 ] ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">"; QueryFormSymbol "?v"; QueryFormInt 1L ] ] ] in assert_equal_query "parse_query accepts map scalar arguments for relation :in bindings" - [ [ Result_value (Keyword "b"); Result_value (Int 2) ] - ; [ Result_value (Keyword "c"); Result_value (Int 3) ] + [ [ Result_value (Keyword "b"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "c"); Result_value (Int64 3L) ] ] (q ~inputs: [ Arg_scalar - (Result_value (Map [ Keyword "a", Int 1; Keyword "b", Int 2; Keyword "c", Int 3 ])) + (Result_value (Map [ Keyword "a", Int64 1L; Keyword "b", Int64 2L; Keyword "c", Int64 3L ])) ] db (parse_query map_relation_query)); @@ -6828,17 +6828,17 @@ let test_parse_query_in_bindings () = in assert_equal_query "parse_query accepts map scalar arguments for nested relation :in bindings" - [ [ Result_value (Keyword "a"); Result_value (Int 1); Result_value (Int 4) ] - ; [ Result_value (Keyword "b"); Result_value (Int 5); Result_value (Int 7) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 1L); Result_value (Int64 4L) ] + ; [ Result_value (Keyword "b"); Result_value (Int64 5L); Result_value (Int64 7L) ] ] (q ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", List [ Int 1; Int 4 ] - ; Keyword "b", List [ Int 5; Int 7 ] - ; Keyword "c", List [ Int 3; Int 3 ] + [ Keyword "a", List [ Int64 1L; Int64 4L ] + ; Keyword "b", List [ Int64 5L; Int64 7L ] + ; Keyword "c", List [ Int64 3L; Int64 3L ] ])) ] db @@ -7080,18 +7080,18 @@ let test_parse_query_find_helper_parser () = (Return_scalar, [ Find_aggregate (MaxN 3, [ QVar "a" ]) ]) (parse_find (QueryFormVector - [ QueryFormList [ QueryFormSymbol "max"; QueryFormInt 3; QueryFormSymbol "?a" ] + [ QueryFormList [ QueryFormSymbol "max"; QueryFormInt 3L; QueryFormSymbol "?a" ] ; QueryFormSymbol "." ])); assert_equal_value "parse_find preserves structured aggregate arguments" - (Return_scalar, [ Find_aggregate (Count, [ QVar "b"; QValue (Int 1); QSource "x" ]) ]) + (Return_scalar, [ Find_aggregate (Count, [ QVar "b"; QValue (Int64 1L); QSource "x" ]) ]) (parse_find (QueryFormVector [ QueryFormList [ QueryFormSymbol "count" ; QueryFormSymbol "?b" - ; QueryFormInt 1 + ; QueryFormInt 1L ; QueryFormSymbol "$x" ] ; QueryFormSymbol "." @@ -7114,11 +7114,11 @@ let test_parse_query_or_join_required_vars () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int 11) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int64 11L) ] } ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg") ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "age", One_value (Int 10); "name", One_value (String "Ivan") ] } - ; Entity { db_id = Some (Entity_id 5); attrs = [ "age", One_value (Int 11); "name", One_value (String "Oleg") ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "age", One_value (Int64 10L); "name", One_value (String "Ivan") ] } + ; Entity { db_id = Some (Entity_id 5); attrs = [ "age", One_value (Int64 11L); "name", One_value (String "Oleg") ] } ] in let query = @@ -7140,7 +7140,7 @@ let test_parse_query_or_join_required_vars () = assert_equal_query "parse_query parses or-join required vars" [ [ Result_entity 1 ]; [ Result_entity 3 ]; [ Result_entity 4 ]; [ Result_entity 5 ] ] - (q ~inputs:[ Arg_scalar (Result_value (Int 10)) ] db (parse_query query)); + (q ~inputs:[ Arg_scalar (Result_value (Int64 10L)) ] db (parse_query query)); let list_rule_vars_query = QueryFormVector [ QueryFormKeyword "find" @@ -7160,7 +7160,7 @@ let test_parse_query_or_join_required_vars () = assert_equal_query "parse_query parses or-join list-form required vars" [ [ Result_entity 1 ]; [ Result_entity 3 ]; [ Result_entity 4 ]; [ Result_entity 5 ] ] - (q ~inputs:[ Arg_scalar (Result_value (Int 10)) ] db (parse_query list_rule_vars_query)); + (q ~inputs:[ Arg_scalar (Result_value (Int64 10L)) ] db (parse_query list_rule_vars_query)); let source_query = QueryFormVector [ QueryFormKeyword "find" @@ -7185,7 +7185,7 @@ let test_parse_query_or_join_required_vars () = "parse_query parses source-qualified or-join required vars" [ [ Result_entity 1 ]; [ Result_entity 3 ]; [ Result_entity 4 ]; [ Result_entity 5 ] ] (q_sources - ~inputs:[ Arg_scalar (Result_value (Int 10)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 10L)) ] (empty_db ()) [ "people", Db_source db ] (parse_query source_query)); @@ -7492,9 +7492,9 @@ let test_parse_query_with_vars () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "monster", One_value (String "Medusa"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "monster", One_value (String "Cyclops"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "monster", One_value (String "Chimera"); "heads", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "monster", One_value (String "Medusa"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "monster", One_value (String "Cyclops"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "monster", One_value (String "Chimera"); "heads", One_value (Int64 1L) ] } ] in let aggregate_query = @@ -7510,7 +7510,7 @@ let test_parse_query_with_vars () = in assert_equal_query "parse_query applies :with vars to aggregate duplicate preservation" - [ [ Result_value (Int 3) ] ] + [ [ Result_value (Int64 3L) ] ] (q db (parse_query aggregate_query)); let relation_query = QueryFormVector @@ -7525,7 +7525,7 @@ let test_parse_query_with_vars () = in assert_equal_query "parse_query applies :with vars to non-aggregate duplicate preservation" - [ [ Result_value (Int 1) ]; [ Result_value (Int 1) ]; [ Result_value (Int 1) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 1L) ]; [ Result_value (Int64 1L) ] ] (q db (parse_query relation_query)); assert_raises_invalid_arg "parse_query rejects duplicate :with variables" @@ -7680,7 +7680,7 @@ let test_q_input_arity_matches_upstream_validation_messages () = (q_string db "[:find ?a :in $ :where [?a]]" - ~inputs:[ Arg_scalar (Result_value (Int 1)) ])); + ~inputs:[ Arg_scalar (Result_value (Int64 1L)) ])); assert_raises_invalid_arg_message "q reports too many supplied input args for inferred default source like upstream" "Extra inputs passed, expected: [$], got: 2" @@ -7689,7 +7689,7 @@ let test_q_input_arity_matches_upstream_validation_messages () = (q_string db "[:find ?a :where [?a]]" - ~inputs:[ Arg_scalar (Result_value (Int 1)) ])) + ~inputs:[ Arg_scalar (Result_value (Int64 1L)) ])) let test_q_input_binding_matches_upstream_validation_messages () = let db = empty_db () in @@ -7725,10 +7725,10 @@ let test_parse_query_map_sections_accept_list_sequences () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 24) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 17) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 24L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 17L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } ] in let query = @@ -7756,22 +7756,22 @@ let test_parse_query_map_sections_accept_list_sequences () = ] ; QueryFormVector [ QueryFormSymbol "?entity"; QueryFormKeyword "name"; QueryFormSymbol "?name" ] ; QueryFormVector [ QueryFormSymbol "?entity"; QueryFormKeyword "age"; QueryFormSymbol "?age" ] - ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">="; QueryFormSymbol "?age"; QueryFormInt 18 ] ] + ; QueryFormVector [ QueryFormList [ QueryFormSymbol ">="; QueryFormSymbol "?age"; QueryFormInt 18L ] ] ] ] ] in assert_equal_query "parse_query accepts list sequences in map query sections" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q ~inputs:[ Arg_scalar (Result_value (String "Ivan")) ] db (parse_query query)) let test_parse_query_concatenates_repeated_sections () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } ] in let query = @@ -7781,7 +7781,7 @@ let test_parse_query_concatenates_repeated_sections () = ; QueryFormKeyword "where" ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "name"; QueryFormSymbol "?name" ] ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 31 ] + ; QueryFormVector [ QueryFormSymbol "?e"; QueryFormKeyword "age"; QueryFormInt 31L ] ] in assert_equal_query @@ -7887,9 +7887,9 @@ let test_q_short_data_patterns_match_upstream () = |> db_with [ Entity { db_id = Some (Entity_id 1) - ; attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] + ; attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int 37) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int64 37L) ] } ] in assert_equal_query @@ -7905,10 +7905,10 @@ let test_q_upstream_query_cljc_parity_batch () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 37) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "age", One_value (Int 15) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 37L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "age", One_value (Int64 15L) ] } ] in assert_equal_query @@ -7917,8 +7917,8 @@ let test_q_upstream_query_cljc_parity_batch () = (q_string db "[:find ?e :where [?e :name]]"); assert_equal_query "query.cljc test-joins joins constants and variables" - [ [ Result_entity 1; Result_value (Int 15) ] - ; [ Result_entity 3; Result_value (Int 37) ] + [ [ Result_entity 1; Result_value (Int64 15L) ] + ; [ Result_entity 3; Result_value (Int64 37L) ] ] (q_string db @@ -7965,14 +7965,14 @@ let test_q_upstream_query_cljc_parity_batch () = [?e2 :name ?n2]]"); assert_equal_query "query.cljc test-built-in-get binds map inputs as relation rows" - [ [ Result_value (Map [ Keyword "d", Int 2 ]); Result_value (Int 2) ] ] + [ [ Result_value (Map [ Keyword "d", Int64 2L ]); Result_value (Int64 2L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", Map [ Keyword "b", Int 1 ] - ; Keyword "c", Map [ Keyword "d", Int 2 ] + [ Keyword "a", Map [ Keyword "b", Int64 1L ] + ; Keyword "c", Map [ Keyword "d", Int64 2L ] ])) ; Arg_scalar (Result_value (Keyword "d")) ] @@ -7991,14 +7991,14 @@ let test_query__test_q_coll () = let relation = Relation_source [ [ Result_entity 1; Result_attr "name"; Result_value (String "Ivan") ] - ; [ Result_entity 1; Result_attr "age"; Result_value (Int 19) ] + ; [ Result_entity 1; Result_attr "age"; Result_value (Int64 19L) ] ; [ Result_entity 1; Result_attr "aka"; Result_value (String "dragon_killer_94") ] ; [ Result_entity 1; Result_attr "aka"; Result_value (String "-=autobot=-") ] ] in assert_equal_query "query.cljc test-q-coll queries relation source datoms" - [ [ Result_value (String "Ivan"); Result_value (Int 19) ] ] + [ [ Result_value (String "Ivan"); Result_value (Int64 19L) ] ] (q_sources_string (empty_db ()) [ "$", relation ] @@ -8012,13 +8012,13 @@ let test_query__test_q_coll () = [ [ Result_entity 1 ; Result_attr "name" ; Result_value (String "Ivan") - ; Result_value (Int 945) + ; Result_value (Int64 945L) ; Result_value (Keyword "db/add") ] ; [ Result_entity 1 ; Result_attr "age" - ; Result_value (Int 39) - ; Result_value (Int 999) + ; Result_value (Int64 39L) + ; Result_value (Int64 999L) ; Result_value (Keyword "db/retract") ] ] @@ -8036,8 +8036,8 @@ let test_query__test_q_coll () = "query.cljc test-q-coll matches full long tuples" [ [ Result_entity 1 ; Result_attr "age" - ; Result_value (Int 39) - ; Result_value (Int 999) + ; Result_value (Int64 39L) + ; Result_value (Int64 999L) ] ] (q_sources_string @@ -8051,9 +8051,9 @@ let test_query__test_q_in () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 37) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 37L) ] } ] in assert_equal_query @@ -8065,7 +8065,7 @@ let test_query__test_q_in () = "[:find ?e :in $ ?attr ?value :where [?e ?attr ?value]]"); assert_equal_query "query.cljc test-q-in supports named db inputs" - [ [ Result_attr "age"; Result_value (Int 15) ] + [ [ Result_attr "age"; Result_value (Int64 15L) ] ; [ Result_attr "name"; Result_value (String "Ivan") ] ] (q_sources_string @@ -8095,9 +8095,9 @@ let test_query__test_q_in () = [$b ?n ?email]]"); assert_equal_query "query.cljc test-q-in supports queries without db sources" - [ [ Result_value (Int 10); Result_value (Int 20) ] ] + [ [ Result_value (Int64 10L); Result_value (Int64 20L) ] ] (q_string - ~inputs:[ Arg_scalar (Result_value (Int 10)); Arg_scalar (Result_value (Int 20)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 10L)); Arg_scalar (Result_value (Int64 20L)) ] (empty_db ()) "[:find ?a ?b :in ?a ?b]") @@ -8105,9 +8105,9 @@ let test_query__test_bindings () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 37) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 37L) ] } ] in assert_equal_query @@ -8131,7 +8131,7 @@ let test_query__test_bindings () = "query.cljc test-bindings handles tuple bindings" [ [ Result_entity 3 ] ] (q_string - ~inputs:[ Arg_tuple [ Result_value (String "Ivan"); Result_value (Int 37) ] ] + ~inputs:[ Arg_tuple [ Result_value (String "Ivan"); Result_value (Int64 37L) ] ] db "[:find ?e :in $ [?name ?age] @@ -8139,7 +8139,7 @@ let test_query__test_bindings () = [?e :age ?age]]"); assert_equal_query "query.cljc test-bindings handles collection bindings" - [ [ Result_attr "age"; Result_value (Int 15) ] + [ [ Result_attr "age"; Result_value (Int64 15L) ] ; [ Result_attr "name"; Result_value (String "Ivan") ] ] (q_string @@ -8213,11 +8213,11 @@ let test_query__test_bindings () = let test_query__test_nested_bindings () = assert_equal_query "query.cljc test-nested-bindings handles map relation inputs" - [ [ Result_value (Keyword "b"); Result_value (Int 2) ] - ; [ Result_value (Keyword "c"); Result_value (Int 3) ] + [ [ Result_value (Keyword "b"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "c"); Result_value (Int64 3L) ] ] (q_string - ~inputs:[ Arg_scalar (Result_value (Map [ Keyword "a", Int 1; Keyword "b", Int 2; Keyword "c", Int 3 ])) ] + ~inputs:[ Arg_scalar (Result_value (Map [ Keyword "a", Int64 1L; Keyword "b", Int64 2L; Keyword "c", Int64 3L ])) ] (empty_db ()) "[:find ?k ?v :in [[?k ?v] ...] @@ -8230,29 +8230,29 @@ let test_query__test_nested_bindings () = let min_value, max_value = List.fold_left (fun (min_value, max_value) -> function - | Int value -> min min_value value, max max_value value + | Int64 value -> Int64.min min_value value, Int64.max max_value value | _ -> min_value, max_value) (match first with - | Int value -> value, value - | _ -> 0, 0) + | Int64 value -> value, value + | _ -> 0L, 0L) rest in - Some [ Result_value (Int min_value); Result_value (Int max_value) ]) + Some [ Result_value (Int64 min_value); Result_value (Int64 max_value) ]) | _ -> None in assert_equal_query "query.cljc test-nested-bindings handles dynamic tuple outputs" - [ [ Result_value (Keyword "a"); Result_value (Int 1); Result_value (Int 4) ] - ; [ Result_value (Keyword "b"); Result_value (Int 5); Result_value (Int 7) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 1L); Result_value (Int64 4L) ] + ; [ Result_value (Keyword "b"); Result_value (Int64 5L); Result_value (Int64 7L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", List [ Int 1; Int 2; Int 3; Int 4 ] - ; Keyword "b", List [ Int 5; Int 6; Int 7 ] - ; Keyword "c", List [ Int 3 ] + [ Keyword "a", List [ Int64 1L; Int64 2L; Int64 3L; Int64 4L ] + ; Keyword "b", List [ Int64 5L; Int64 6L; Int64 7L ] + ; Keyword "c", List [ Int64 3L ] ])) ; Arg_function minmax ] @@ -8262,28 +8262,28 @@ let test_query__test_nested_bindings () = :where [(?minmax ?v) [?min ?max]] [(> ?max ?min)]]"); let range_values = function - | [ Result_value (Int min_value); Result_value (Int max_value) ] -> + | [ Result_value (Int64 min_value); Result_value (Int64 max_value) ] -> let rec collect value acc = if value >= max_value then List.rev acc - else collect (value + 1) (Int value :: acc) + else collect (Int64.add value 1L) (Int64 value :: acc) in Some [ Result_value (List (collect min_value [])) ] | _ -> None in assert_equal_query "query.cljc test-nested-bindings handles dynamic collection outputs" - [ [ Result_value (Keyword "a"); Result_value (Int 2) ] - ; [ Result_value (Keyword "a"); Result_value (Int 4) ] - ; [ Result_value (Keyword "a"); Result_value (Int 6) ] - ; [ Result_value (Keyword "b"); Result_value (Int 2) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "a"); Result_value (Int64 4L) ] + ; [ Result_value (Keyword "a"); Result_value (Int64 6L) ] + ; [ Result_value (Keyword "b"); Result_value (Int64 2L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", List [ Int 1; Int 7 ] - ; Keyword "b", List [ Int 2; Int 4 ] + [ Keyword "a", List [ Int64 1L; Int64 7L ] + ; Keyword "b", List [ Int64 2L; Int64 4L ] ])) ; Arg_function range_values ] @@ -8298,7 +8298,7 @@ let test_query__test_built_in_get () = let test_query__test_join_unrelated () = let five = function - | [] -> Some [ Result_value (Int 5) ] + | [] -> Some [ Result_value (Int64 5L) ] | _ -> None in assert_equal_query @@ -8433,12 +8433,12 @@ let test_q_predicates_filter_bound_values () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 19) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 19L) ] } ] in let adult = function - | [ Result_value (Int age) ] -> age >= 21 + | [ Result_value (Int64 age) ] -> age >= 21L | _ -> false in let query = @@ -8490,12 +8490,12 @@ let test_q_functions_bind_derived_values () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 19) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 19L) ] } ] in let decade = function - | [ Result_value (Int age) ] -> Some [ Result_value (Int (age / 10 * 10)) ] + | [ Result_value (Int64 age) ] -> Some [ Result_value (Int64 (Int64.mul (Int64.div age 10L) 10L)) ] | _ -> None in let query = @@ -8512,8 +8512,8 @@ let test_q_functions_bind_derived_values () = in assert_equal_query "q functions bind derived values" - [ [ Result_value (String "Ivan"); Result_value (Int 30) ] - ; [ Result_value (String "Petr"); Result_value (Int 10) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 30L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 10L) ] ] (q db query) @@ -8521,13 +8521,13 @@ let test_q_functions_filter_on_none () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 19) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 19L) ] } ] in let adult_label = function - | [ Result_value (Int age) ] when age >= 21 -> Some [ Result_value (String "adult") ] - | [ Result_value (Int _) ] -> None + | [ Result_value (Int64 age) ] when age >= 21L -> Some [ Result_value (String "adult") ] + | [ Result_value (Int64 _) ] -> None | _ -> None in let query = @@ -8564,8 +8564,8 @@ let test_q_function_binding_conflicts_filter_rows () = ; with_vars = [] ; rules = [] ; where = - [ Function ("identity", [], [ "n" ], identity (Int 1)) - ; Function ("identity", [], [ "n" ], identity (Int 2)) + [ Function ("identity", [], [ "n" ], identity (Int64 1L)) + ; Function ("identity", [], [ "n" ], identity (Int64 2L)) ] }); assert_equal_query @@ -8578,15 +8578,15 @@ let test_q_function_binding_conflicts_filter_rows () = ; with_vars = [] ; rules = [] ; where = - [ Function ("identity", [], [ "n"; "x" ], tuple (Tuple [ Some (Int 3); Some (Int 4) ])) - ; Function ("identity", [], [ "n"; "x" ], tuple (Tuple [ Some (Int 1); Some (Int 2) ])) + [ Function ("identity", [], [ "n"; "x" ], tuple (Tuple [ Some (Int64 3L); Some (Int64 4L) ])) + ; Function ("identity", [], [ "n"; "x" ], tuple (Tuple [ Some (Int64 1L); Some (Int64 2L) ])) ] }); let db = empty_db () |> db_with - [ Add (Entity_id 1, "age", Int 15) - ; Add (Entity_id 2, "age", Int 35) + [ Add (Entity_id 1, "age", Int64 15L) + ; Add (Entity_id 2, "age", Int64 35L) ] in assert_equal_query @@ -8600,7 +8600,7 @@ let test_q_function_binding_conflicts_filter_rows () = ; rules = [] ; where = [ Pattern (QWildcard, QAttr "age", QVar "age") - ; Function ("identity", [], [ "age" ], identity (Int 100)) + ; Function ("identity", [], [ "age" ], identity (Int64 100L)) ] }); assert_equal_query @@ -8613,7 +8613,7 @@ let test_q_function_binding_conflicts_filter_rows () = ; with_vars = [] ; rules = [] ; where = - [ Function ("identity", [], [ "age" ], identity (Int 100)) + [ Function ("identity", [], [ "age" ], identity (Int64 100L)) ; Pattern (QWildcard, QAttr "age", QVar "age") ] }) @@ -8623,21 +8623,21 @@ let test_q_function_bindings_interact_with_rules () = let rules = [ { rule_name = "my-vals" ; rule_params = [ "x" ] - ; rule_body = [ Function ("identity", [], [ "x" ], identity (Int 1)) ] + ; rule_body = [ Function ("identity", [], [ "x" ], identity (Int64 1L)) ] } ; { rule_name = "my-vals" ; rule_params = [ "x" ] - ; rule_body = [ Function ("identity", [], [ "x" ], identity (Int 2)) ] + ; rule_body = [ Function ("identity", [], [ "x" ], identity (Int64 2L)) ] } ; { rule_name = "my-vals" ; rule_params = [ "x" ] - ; rule_body = [ Function ("identity", [], [ "x" ], identity (Int 3)) ] + ; rule_body = [ Function ("identity", [], [ "x" ], identity (Int64 3L)) ] } ] in assert_equal_query "q rule bindings are filtered by prior function bindings" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q (empty_db ()) { find = [ Find_var "n" ] @@ -8645,13 +8645,13 @@ let test_q_function_bindings_interact_with_rules () = ; with_vars = [] ; rules ; where = - [ Function ("identity", [], [ "n" ], identity (Int 2)) + [ Function ("identity", [], [ "n" ], identity (Int64 2L)) ; Rule ("my-vals", [ QVar "n" ]) ] }); assert_equal_query "q function bindings are filtered by prior rule bindings" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q (empty_db ()) { find = [ Find_var "n" ] @@ -8660,7 +8660,7 @@ let test_q_function_bindings_interact_with_rules () = ; rules ; where = [ Rule ("my-vals", [ QVar "n" ]) - ; Function ("identity", [], [ "n" ], identity (Int 2)) + ; Function ("identity", [], [ "n" ], identity (Int64 2L)) ] }) @@ -8668,21 +8668,21 @@ let test_q_parsed_rule_inputs_interact_with_function_bindings () = let rules = [ { rule_name = "my-vals" ; rule_params = [ "x" ] - ; rule_body = [ IdentityValue (QValue (Int 1), "x") ] + ; rule_body = [ IdentityValue (QValue (Int64 1L), "x") ] } ; { rule_name = "my-vals" ; rule_params = [ "x" ] - ; rule_body = [ IdentityValue (QValue (Int 2), "x") ] + ; rule_body = [ IdentityValue (QValue (Int64 2L), "x") ] } ; { rule_name = "my-vals" ; rule_params = [ "x" ] - ; rule_body = [ IdentityValue (QValue (Int 3), "x") ] + ; rule_body = [ IdentityValue (QValue (Int64 3L), "x") ] } ] in assert_equal_query "q_string applies rules supplied through % after prior function bindings" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q_string ~inputs:[ Arg_rules rules ] (empty_db ()) @@ -8692,7 +8692,7 @@ let test_q_parsed_rule_inputs_interact_with_function_bindings () = (my-vals ?n)]"); assert_equal_query "q_string applies function bindings after rules supplied through %" - [ [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 2L) ] ] (q_string ~inputs:[ Arg_rules rules ] (empty_db ()) @@ -8862,8 +8862,8 @@ let test_q_parsed_rule_inputs_interact_with_function_bindings () = let db = empty_db () |> db_with - [ Add (Entity_id 1, "age", Int 15) - ; Add (Entity_id 2, "age", Int 35) + [ Add (Entity_id 1, "age", Int64 15L) + ; Add (Entity_id 2, "age", Int64 35L) ] in assert_equal_query @@ -8904,7 +8904,7 @@ let test_q_predicates_and_functions_reject_unbound_inputs () = , [ QVar "x" ] , [ "y" ] , (function - | [ Result_value (Int x) ] -> Some [ Result_value (Int (x + 1)) ] + | [ Result_value (Int64 x) ] -> Some [ Result_value (Int64 (Int64.add x 1L)) ] | _ -> None) ) ] })) @@ -8913,9 +8913,9 @@ let test_q_builtin_get_else_get_some_and_missing () = let db = empty_db ~schema:[ "parent", ref_attr ] () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 22); "height", One_value (Int 240); "parent", One_value (Ref 1) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Slava"); "age", One_value (Int 37); "parent", One_value (Ref 2) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 22L); "height", One_value (Int64 240L); "parent", One_value (Ref 1) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Slava"); "age", One_value (Int64 37L); "parent", One_value (Ref 2) ] } ] in let get_else_query = @@ -8925,15 +8925,15 @@ let test_q_builtin_get_else_get_some_and_missing () = ; rules = [] ; where = [ Pattern (QVar "e", QAttr "age", QVar "age") - ; GetElse (QVar "e", QAttr "height", QValue (Int 300), "height") + ; GetElse (QVar "e", QAttr "height", QValue (Int64 300L), "height") ] } in assert_equal_query "q get-else returns existing values or the default" - [ [ Result_entity 1; Result_value (Int 15); Result_value (Int 300) ] - ; [ Result_entity 2; Result_value (Int 22); Result_value (Int 240) ] - ; [ Result_entity 3; Result_value (Int 37); Result_value (Int 300) ] + [ [ Result_entity 1; Result_value (Int64 15L); Result_value (Int64 300L) ] + ; [ Result_entity 2; Result_value (Int64 22L); Result_value (Int64 240L) ] + ; [ Result_entity 3; Result_value (Int64 37L); Result_value (Int64 300L) ] ] (q db get_else_query); assert_equal_query @@ -8967,9 +8967,9 @@ let test_q_builtin_get_else_get_some_and_missing () = in assert_equal_query "q get-some returns the first present attr and value" - [ [ Result_entity 1; Result_attr "age"; Result_value (Int 15) ] - ; [ Result_entity 2; Result_attr "height"; Result_value (Int 240) ] - ; [ Result_entity 3; Result_attr "age"; Result_value (Int 37) ] + [ [ Result_entity 1; Result_attr "age"; Result_value (Int64 15L) ] + ; [ Result_entity 2; Result_attr "height"; Result_value (Int64 240L) ] + ; [ Result_entity 3; Result_attr "age"; Result_value (Int64 37L) ] ] (q db get_some_query); let missing_query = @@ -8985,7 +8985,7 @@ let test_q_builtin_get_else_get_some_and_missing () = in assert_equal_query "q missing filters entities that have no value for attr" - [ [ Result_entity 1; Result_value (Int 15) ]; [ Result_entity 3; Result_value (Int 37) ] ] + [ [ Result_entity 1; Result_value (Int64 15L) ]; [ Result_entity 3; Result_value (Int64 37L) ] ] (q db missing_query); let reverse_missing_query = { find = [ Find_var "e" ] @@ -9024,15 +9024,15 @@ let test_q_builtin_get_else_get_some_and_missing () = ; rules = [] ; where = [ SourcePattern ("people", QVar "e", QAttr "age", QWildcard) - ; SourceGetElse ("people", QVar "e", QAttr "height", QValue (Int 300), "height") + ; SourceGetElse ("people", QVar "e", QAttr "height", QValue (Int64 300L), "height") ] } in assert_equal_query "q source get-else evaluates against the named source" - [ [ Result_entity 1; Result_value (Int 300) ] - ; [ Result_entity 2; Result_value (Int 240) ] - ; [ Result_entity 3; Result_value (Int 300) ] + [ [ Result_entity 1; Result_value (Int64 300L) ] + ; [ Result_entity 2; Result_value (Int64 240L) ] + ; [ Result_entity 3; Result_value (Int64 300L) ] ] (q_sources (empty_db ()) [ "people", Db_source db ] source_get_else_query); let source_get_some_query = @@ -9048,9 +9048,9 @@ let test_q_builtin_get_else_get_some_and_missing () = in assert_equal_query "q source get-some evaluates against the named source" - [ [ Result_entity 1; Result_attr "age"; Result_value (Int 15) ] - ; [ Result_entity 2; Result_attr "height"; Result_value (Int 240) ] - ; [ Result_entity 3; Result_attr "age"; Result_value (Int 37) ] + [ [ Result_entity 1; Result_attr "age"; Result_value (Int64 15L) ] + ; [ Result_entity 2; Result_attr "height"; Result_value (Int64 240L) ] + ; [ Result_entity 3; Result_attr "age"; Result_value (Int64 37L) ] ] (q_sources (empty_db ()) [ "people", Db_source db ] source_get_some_query) @@ -9060,8 +9060,8 @@ let test_q_builtin_get_map_values () = ; inputs = [ Input_relation ( [ "label"; "m" ] - , [ [ Result_value (Keyword "a"); Result_value (Map [ Keyword "b", Int 1 ]) ] - ; [ Result_value (Keyword "c"); Result_value (Map [ Keyword "d", Int 2 ]) ] + , [ [ Result_value (Keyword "a"); Result_value (Map [ Keyword "b", Int64 1L ]) ] + ; [ Result_value (Keyword "c"); Result_value (Map [ Keyword "d", Int64 2L ]) ] ] ) ; Input_scalar ("key", Result_value (Keyword "d")) @@ -9076,7 +9076,7 @@ let test_q_builtin_get_map_values () = in assert_equal_query "q get returns map values and default values for missing keys" - [ [ Result_value (Int 2); Result_value (String "fallback") ] ] + [ [ Result_value (Int64 2L); Result_value (String "fallback") ] ] (q (empty_db ()) query); let collection_query = { find = [ Find_var "label"; Find_var "value" ] @@ -9085,7 +9085,7 @@ let test_q_builtin_get_map_values () = ( [ "label"; "coll"; "key"; "default" ] , [ [ Result_value (String "list") ; Result_value (List [ String "zero"; String "one" ]) - ; Result_value (Int 1) + ; Result_value (Int64 1L) ; Result_value (String "missing") ] ; [ Result_value (String "set") @@ -9094,13 +9094,13 @@ let test_q_builtin_get_map_values () = ; Result_value (String "missing") ] ; [ Result_value (String "tuple-nil") - ; Result_value (Tuple [ Some (Int 10); None; Some (Int 30) ]) - ; Result_value (Int 1) + ; Result_value (Tuple [ Some (Int64 10L); None; Some (Int64 30L) ]) + ; Result_value (Int64 1L) ; Result_value (String "missing") ] ; [ Result_value (String "default") ; Result_value (List [ String "zero" ]) - ; Result_value (Int 4) + ; Result_value (Int64 4L) ; Result_value (String "missing") ] ] @@ -9128,7 +9128,7 @@ let test_q_builtin_count_values () = ( "x" , [ Result_value (String "a") ; Result_value (String "abc") - ; Result_value (List [ Int 1; Int 2 ]) + ; Result_value (List [ Int64 1L; Int64 2L ]) ] ) ] @@ -9139,9 +9139,9 @@ let test_q_builtin_count_values () = in assert_equal_query "q count returns string and collection sizes" - [ [ Result_value (String "a"); Result_value (Int 1) ] - ; [ Result_value (String "abc"); Result_value (Int 3) ] - ; [ Result_value (List [ Int 1; Int 2 ]); Result_value (Int 2) ] + [ [ Result_value (String "a"); Result_value (Int64 1L) ] + ; [ Result_value (String "abc"); Result_value (Int64 3L) ] + ; [ Result_value (List [ Int64 1L; Int64 2L ]); Result_value (Int64 2L) ] ] (q (empty_db ()) query) @@ -9152,11 +9152,11 @@ let test_q_builtin_empty_and_not_empty_values () = , [ Result_value (String "") ; Result_value (String "a") ; Result_value (List []) - ; Result_value (List [ Int 1 ]) + ; Result_value (List [ Int64 1L ]) ; Result_value (Set []) - ; Result_value (Set [ Int 1 ]) + ; Result_value (Set [ Int64 1L ]) ; Result_value (Map []) - ; Result_value (Map [ Keyword "a", Int 1 ]) + ; Result_value (Map [ Keyword "a", Int64 1L ]) ] ) ] @@ -9176,9 +9176,9 @@ let test_q_builtin_empty_and_not_empty_values () = assert_equal_query "q not-empty filters non-empty values" [ [ Result_value (String "a") ] - ; [ Result_value (List [ Int 1 ]) ] - ; [ Result_value (Map [ Keyword "a", Int 1 ]) ] - ; [ Result_value (Set [ Int 1 ]) ] + ; [ Result_value (List [ Int64 1L ]) ] + ; [ Result_value (Map [ Keyword "a", Int64 1L ]) ] + ; [ Result_value (Set [ Int64 1L ]) ] ] (q (empty_db ()) not_empty_query) @@ -9188,12 +9188,12 @@ let test_q_builtin_contains_values () = ; inputs = [ Input_relation ( [ "label"; "coll"; "key" ] - , [ [ Result_value (String "map"); Result_value (Map [ Keyword "a", Int 1 ]); Result_value (Keyword "a") ] - ; [ Result_value (String "map-miss"); Result_value (Map [ Keyword "a", Int 1 ]); Result_value (Keyword "b") ] - ; [ Result_value (String "set"); Result_value (Set [ Int 1; Int 2 ]); Result_value (Int 2) ] - ; [ Result_value (String "set-miss"); Result_value (Set [ Int 1; Int 2 ]); Result_value (Int 3) ] - ; [ Result_value (String "list"); Result_value (List [ String "a"; String "b" ]); Result_value (Int 1) ] - ; [ Result_value (String "list-miss"); Result_value (List [ String "a"; String "b" ]); Result_value (Int 2) ] + , [ [ Result_value (String "map"); Result_value (Map [ Keyword "a", Int64 1L ]); Result_value (Keyword "a") ] + ; [ Result_value (String "map-miss"); Result_value (Map [ Keyword "a", Int64 1L ]); Result_value (Keyword "b") ] + ; [ Result_value (String "set"); Result_value (Set [ Int64 1L; Int64 2L ]); Result_value (Int64 2L) ] + ; [ Result_value (String "set-miss"); Result_value (Set [ Int64 1L; Int64 2L ]); Result_value (Int64 3L) ] + ; [ Result_value (String "list"); Result_value (List [ String "a"; String "b" ]); Result_value (Int64 1L) ] + ; [ Result_value (String "list-miss"); Result_value (List [ String "a"; String "b" ]); Result_value (Int64 2L) ] ] ) ] @@ -9213,7 +9213,7 @@ let test_q_builtin_value_type_predicates () = ( [ "label"; "x" ] , [ [ Result_value (String "bool"); Result_value (Bool true) ] ; [ Result_value (String "float"); Result_value (Float 2.5) ] - ; [ Result_value (String "int"); Result_value (Int 1) ] + ; [ Result_value (String "int"); Result_value (Int64 1L) ] ; [ Result_value (String "keyword"); Result_value (Keyword "user/name") ] ; [ Result_value (String "string"); Result_value (String "Ivan") ] ] @@ -9250,10 +9250,10 @@ let test_q_builtin_numeric_predicates () = ( [ "label"; "x" ] , [ [ Result_value (String "float-positive"); Result_value (Float 1.5) ] ; [ Result_value (String "float-zero"); Result_value (Float 0.0) ] - ; [ Result_value (String "negative"); Result_value (Int (-2)) ] - ; [ Result_value (String "odd-negative"); Result_value (Int (-1)) ] - ; [ Result_value (String "positive"); Result_value (Int 3) ] - ; [ Result_value (String "zero"); Result_value (Int 0) ] + ; [ Result_value (String "negative"); Result_value (Int64 (-2L)) ] + ; [ Result_value (String "odd-negative"); Result_value (Int64 (-1L)) ] + ; [ Result_value (String "positive"); Result_value (Int64 3L) ] + ; [ Result_value (String "zero"); Result_value (Int64 0L) ] ; [ Result_value (String "string"); Result_value (String "0") ] ] ) @@ -9287,10 +9287,10 @@ let test_q_builtin_comparison_predicates () = let inputs = [ Input_relation ( [ "label"; "x"; "y" ] - , [ [ Result_value (String "equal"); Result_value (Int 2); Result_value (Float 2.0) ] - ; [ Result_value (String "greater"); Result_value (Int 3); Result_value (Int 2) ] + , [ [ Result_value (String "equal"); Result_value (Int64 2L); Result_value (Float 2.0) ] + ; [ Result_value (String "greater"); Result_value (Int64 3L); Result_value (Int64 2L) ] ; [ Result_value (String "keyword"); Result_value (Keyword "user/name"); Result_value (Keyword "user/score") ] - ; [ Result_value (String "less"); Result_value (Int 1); Result_value (Int 2) ] + ; [ Result_value (String "less"); Result_value (Int64 1L); Result_value (Int64 2L) ] ] ) ] @@ -9321,9 +9321,9 @@ let test_q_builtin_variadic_comparison_predicates () = let inputs = [ Input_relation ( [ "label"; "x"; "y"; "z" ] - , [ [ Result_value (String "ascending"); Result_value (Int 1); Result_value (Int 2); Result_value (Int 3) ] - ; [ Result_value (String "descending"); Result_value (Int 3); Result_value (Int 2); Result_value (Int 1) ] - ; [ Result_value (String "equal"); Result_value (Int 2); Result_value (Int 2); Result_value (Int 2) ] + , [ [ Result_value (String "ascending"); Result_value (Int64 1L); Result_value (Int64 2L); Result_value (Int64 3L) ] + ; [ Result_value (String "descending"); Result_value (Int64 3L); Result_value (Int64 2L); Result_value (Int64 1L) ] + ; [ Result_value (String "equal"); Result_value (Int64 2L); Result_value (Int64 2L); Result_value (Int64 2L) ] ] ) ] @@ -9359,8 +9359,8 @@ let test_q_builtin_equality_predicates () = let inputs = [ Input_relation ( [ "label"; "x"; "y"; "z" ] - , [ [ Result_value (String "all-equal"); Result_value (Int 1); Result_value (Float 1.0); Result_value (Int 1) ] - ; [ Result_value (String "different"); Result_value (Int 1); Result_value (Int 2); Result_value (Int 1) ] + , [ [ Result_value (String "all-equal"); Result_value (Int64 1L); Result_value (Float 1.0); Result_value (Int64 1L) ] + ; [ Result_value (String "different"); Result_value (Int64 1L); Result_value (Int64 2L); Result_value (Int64 1L) ] ; [ Result_value (String "keyword-equal"); Result_value (Keyword "a/b"); Result_value (Keyword "a/b"); Result_value (Keyword "a/b") ] ] ) @@ -9396,7 +9396,7 @@ let test_q_builtin_arithmetic_values () = ; Find_var "decremented" ] ; inputs = - [ Input_scalar ("x", Result_value (Int 6)) + [ Input_scalar ("x", Result_value (Int64 6L)) ; Input_scalar ("y", Result_value (Float 2.5)) ] ; with_vars = [] @@ -9405,7 +9405,7 @@ let test_q_builtin_arithmetic_values () = [ ArithmeticValue (AddNumbers, [ QVar "x"; QVar "y" ], "sum") ; ArithmeticValue (SubtractNumbers, [ QVar "x"; QVar "y" ], "difference") ; ArithmeticValue (MultiplyNumbers, [ QVar "x"; QVar "y" ], "product") - ; ArithmeticValue (DivideNumbers, [ QVar "x"; QValue (Int 2) ], "quotient") + ; ArithmeticValue (DivideNumbers, [ QVar "x"; QValue (Int64 2L) ], "quotient") ; ArithmeticValue (IncrementNumber, [ QVar "x" ], "incremented") ; ArithmeticValue (DecrementNumber, [ QVar "x" ], "decremented") ] @@ -9416,9 +9416,9 @@ let test_q_builtin_arithmetic_values () = [ [ Result_value (Float 8.5) ; Result_value (Float 3.5) ; Result_value (Float 15.0) - ; Result_value (Int 3) - ; Result_value (Int 7) - ; Result_value (Int 5) + ; Result_value (Int64 3L) + ; Result_value (Int64 7L) + ; Result_value (Int64 5L) ] ] (q (empty_db ()) query) @@ -9427,8 +9427,8 @@ let test_q_builtin_integer_arithmetic_values () = let query = { find = [ Find_var "quotient"; Find_var "remainder"; Find_var "modulo" ] ; inputs = - [ Input_scalar ("x", Result_value (Int (-7))) - ; Input_scalar ("y", Result_value (Int 3)) + [ Input_scalar ("x", Result_value (Int64 (-7L))) + ; Input_scalar ("y", Result_value (Int64 3L)) ] ; with_vars = [] ; rules = [] @@ -9441,7 +9441,7 @@ let test_q_builtin_integer_arithmetic_values () = in assert_equal_query "q integer arithmetic built-ins derive quot rem and mod values" - [ [ Result_value (Int (-2)); Result_value (Int (-1)); Result_value (Int 2) ] ] + [ [ Result_value (Int64 (-2L)); Result_value (Int64 (-1L)); Result_value (Int64 2L) ] ] (q (empty_db ()) query) let test_q_builtin_compare_min_max_values () = @@ -9452,17 +9452,17 @@ let test_q_builtin_compare_min_max_values () = ; rules = [] ; where = [ CompareValue (QValue (Keyword "user/name"), QValue (Keyword "user/score"), "comparison") - ; ExtremumValue (MinimumValue, [ QValue (Int 3); QValue (Float 2.5); QValue (Int 4) ], "least") - ; ExtremumValue (MaximumValue, [ QValue (Int 3); QValue (Float 2.5); QValue (Int 4) ], "greatest") + ; ExtremumValue (MinimumValue, [ QValue (Int64 3L); QValue (Float 2.5); QValue (Int64 4L) ], "least") + ; ExtremumValue (MaximumValue, [ QValue (Int64 3L); QValue (Float 2.5); QValue (Int64 4L) ], "greatest") ; ExtremumValue (MinimumValue, [ QValue (Keyword "user/score"); QValue (Keyword "user/name") ], "keyword-min") ] } in assert_equal_query "q compare min and max use DataScript value ordering" - [ [ Result_value (Int (-1)) + [ [ Result_value (Int64 (-1L)) ; Result_value (Float 2.5) - ; Result_value (Int 4) + ; Result_value (Int64 4L) ; Result_value (Keyword "user/name") ] ] @@ -9473,7 +9473,7 @@ let test_q_builtin_boolean_predicates () = [ Input_relation ( [ "label"; "x" ] , [ [ Result_value (String "false"); Result_value (Bool false) ] - ; [ Result_value (String "int"); Result_value (Int 1) ] + ; [ Result_value (String "int"); Result_value (Int64 1L) ] ; [ Result_value (String "nil"); Result_value Nil ] ; [ Result_value (String "true"); Result_value (Bool true) ] ] @@ -9538,20 +9538,20 @@ let test_q_builtin_random_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RandomValue "rand"; RandomIntValue (QValue (Int 10), "rand-int") ] + ; where = [ RandomValue "rand"; RandomIntValue (QValue (Int64 10L), "rand-int") ] } with - | [ [ Result_value (Float rand); Result_value (Int rand_int) ] ] -> + | [ [ Result_value (Float rand); Result_value (Int64 rand_int) ] ] -> if rand < 0.0 || rand >= 1.0 then failwith "rand should be in [0, 1)"; - if rand_int < 0 || rand_int >= 10 then failwith "rand-int should be in [0, n)" + if rand_int < 0L || rand_int >= 10L then failwith "rand-int should be in [0, n)" | _ -> failwith "unexpected random query result" let test_q_builtin_differ_and_identical_predicates () = let inputs = [ Input_relation ( [ "label"; "a"; "b"; "c"; "d" ] - , [ [ Result_value (String "different"); Result_value (Int 1); Result_value (Int 2); Result_value (Int 1); Result_value (Int 3) ] - ; [ Result_value (String "same"); Result_value (Int 1); Result_value (Int 2); Result_value (Float 1.0); Result_value (Int 2) ] + , [ [ Result_value (String "different"); Result_value (Int64 1L); Result_value (Int64 2L); Result_value (Int64 1L); Result_value (Int64 3L) ] + ; [ Result_value (String "same"); Result_value (Int64 1L); Result_value (Int64 2L); Result_value (Float 1.0); Result_value (Int64 2L) ] ] ) ] @@ -9586,9 +9586,9 @@ let test_q_builtin_type_values () = [ Input_relation ( [ "label"; "x" ] , [ [ Result_value (String "bool"); Result_value (Bool true) ] - ; [ Result_value (String "int"); Result_value (Int 1) ] + ; [ Result_value (String "int"); Result_value (Int64 1L) ] ; [ Result_value (String "keyword"); Result_value (Keyword "user/name") ] - ; [ Result_value (String "list"); Result_value (List [ Int 1 ]) ] + ; [ Result_value (String "list"); Result_value (List [ Int64 1L ]) ] ; [ Result_value (String "string"); Result_value (String "Ivan") ] ] ) @@ -9807,7 +9807,7 @@ let test_q_builtin_string_index_values () = in assert_equal_query "q string index built-ins derive first and last match positions" - [ [ Result_value (String "hit"); Result_value (Int 2); Result_value (Int 4) ] ] + [ [ Result_value (String "hit"); Result_value (Int64 2L); Result_value (Int64 4L) ] ] (q (empty_db ()) query) let test_q_builtin_string_substring_values () = @@ -9817,8 +9817,8 @@ let test_q_builtin_string_substring_values () = ; with_vars = [] ; rules = [] ; where = - [ StringSubstringValue (QVar "s", QValue (Int 4), Some (QValue (Int 10)), "part") - ; StringSubstringValue (QVar "s", QValue (Int 4), None, "suffix") + [ StringSubstringValue (QVar "s", QValue (Int64 4L), Some (QValue (Int64 10L)), "part") + ; StringSubstringValue (QVar "s", QValue (Int64 4L), None, "suffix") ] } in @@ -9836,7 +9836,7 @@ let test_q_builtin_string_substring_values () = ; inputs = [ Input_scalar ("s", Result_value (String "data")) ] ; with_vars = [] ; rules = [] - ; where = [ StringSubstringValue (QVar "s", QValue (Int 3), Some (QValue (Int 5)), "part") ] + ; where = [ StringSubstringValue (QVar "s", QValue (Int64 3L), Some (QValue (Int64 5L)), "part") ] })) let test_q_builtin_string_build_and_join_values () = @@ -9845,7 +9845,7 @@ let test_q_builtin_string_build_and_join_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ StringBuildValue ([ QValue (String "score="); QValue (Int 42); QValue (Bool true) ], "s") ] + ; where = [ StringBuildValue ([ QValue (String "score="); QValue (Int64 42L); QValue (Bool true) ], "s") ] } in assert_equal_query @@ -9880,10 +9880,10 @@ let test_q_builtin_print_string_values () = ; with_vars = [] ; rules = [] ; where = - [ PrintStringValue ([ QValue (String "hi"); QValue (Keyword "user/name"); QValue (Int 2) ], "printed") - ; PrStringValue ([ QValue (String "hi"); QValue (Keyword "user/name"); QValue (Int 2) ], "readable") - ; PrintLineStringValue ([ QValue (String "hi"); QValue (Int 2) ], "line") - ; PrnStringValue ([ QValue (String "hi"); QValue (Int 2) ], "readable_line") + [ PrintStringValue ([ QValue (String "hi"); QValue (Keyword "user/name"); QValue (Int64 2L) ], "printed") + ; PrStringValue ([ QValue (String "hi"); QValue (Keyword "user/name"); QValue (Int64 2L) ], "readable") + ; PrintLineStringValue ([ QValue (String "hi"); QValue (Int64 2L) ], "line") + ; PrnStringValue ([ QValue (String "hi"); QValue (Int64 2L) ], "readable_line") ] } in @@ -10043,7 +10043,7 @@ let test_q_builtin_string_blank_and_split_values () = [ StringSplitValue (QVar "csv", QValue (String ","), "parts") ; RePatternValue (QValue (String "[,;]"), "separator") ; StringSplitValue (QVar "mixed", QVar "separator", "regex-parts") - ; StringSplitLimitValue (QVar "mixed", QVar "separator", QValue (Int 2), "limited-parts") + ; StringSplitLimitValue (QVar "mixed", QVar "separator", QValue (Int64 2L), "limited-parts") ; StringSplitLinesValue (QVar "text", "lines") ] } @@ -10066,13 +10066,13 @@ let test_q_builtin_vector_values () = ; rules = [] ; where = [ Ground (Keyword "db/add", "op") - ; VectorValue ([ QVar "op"; QValue (Int (-1)); QAttr "attr"; QValue (Int 12) ], "tx_data") + ; VectorValue ([ QVar "op"; QValue (Int64 (-1L)); QAttr "attr"; QValue (Int64 12L) ], "tx_data") ] } in assert_equal_query "q vector builds a vector value from bound terms" - [ [ Result_value (Vector [ Keyword "db/add"; Int (-1); Keyword "attr"; Int 12 ]) ] ] + [ [ Result_value (Vector [ Keyword "db/add"; Int64 (-1L); Keyword "attr"; Int64 12L ]) ] ] (q (empty_db ()) query) let test_q_builtin_vector_captures_bound_row_values () = @@ -10105,8 +10105,8 @@ let test_q_builtin_hash_map_values () = let query = { find = [ Find_var "m" ] ; inputs = - [ Input_scalar ("left", Result_value (Int 1)) - ; Input_scalar ("right", Result_value (Int 2)) + [ Input_scalar ("left", Result_value (Int64 1L)) + ; Input_scalar ("right", Result_value (Int64 2L)) ] ; with_vars = [] ; rules = [] @@ -10119,7 +10119,7 @@ let test_q_builtin_hash_map_values () = in assert_equal_query "q hash-map builds a map value from bound key/value terms" - [ [ Result_value (Map [ Keyword "left", Int 1; Keyword "right", Int 2 ]) ] ] + [ [ Result_value (Map [ Keyword "left", Int64 1L; Keyword "right", Int64 2L ]) ] ] (q (empty_db ()) query); let array_map_query = { find = [ Find_var "m" ] @@ -10128,21 +10128,21 @@ let test_q_builtin_hash_map_values () = ; rules = [] ; where = [ ArrayMapValue - ( [ QAttr "right"; QValue (Int 2); QAttr "left"; QValue (Int 1) ] + ( [ QAttr "right"; QValue (Int64 2L); QAttr "left"; QValue (Int64 1L) ] , "m" ) ] } in assert_equal_query "q array-map builds a normalized map value from key/value terms" - [ [ Result_value (Map [ Keyword "left", Int 1; Keyword "right", Int 2 ]) ] ] + [ [ Result_value (Map [ Keyword "left", Int64 1L; Keyword "right", Int64 2L ]) ] ] (q (empty_db ()) array_map_query); let odd_query = { find = [ Find_var "m" ] ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ HashMapValue ([ QAttr "left"; QValue (Int 1); QAttr "right" ], "m") ] + ; where = [ HashMapValue ([ QAttr "left"; QValue (Int64 1L); QAttr "right" ], "m") ] } in assert_raises_invalid_arg @@ -10155,24 +10155,24 @@ let test_q_builtin_list_and_set_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ ListValue ([ QValue (Int 2); QValue (Int 1); QValue (Int 1) ], "xs") ] + ; where = [ ListValue ([ QValue (Int64 2L); QValue (Int64 1L); QValue (Int64 1L) ], "xs") ] } in assert_equal_query "q list builds an ordered list value" - [ [ Result_value (List [ Int 2; Int 1; Int 1 ]) ] ] + [ [ Result_value (List [ Int64 2L; Int64 1L; Int64 1L ]) ] ] (q (empty_db ()) list_query); let set_query = { find = [ Find_var "xs" ] ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ SetValue ([ QValue (Int 2); QValue (Int 1); QValue (Int 1) ], "xs") ] + ; where = [ SetValue ([ QValue (Int64 2L); QValue (Int64 1L); QValue (Int64 1L) ], "xs") ] } in assert_equal_query "q set builds a normalized set value" - [ [ Result_value (Set [ Int 1; Int 2 ]) ] ] + [ [ Result_value (Set [ Int64 1L; Int64 2L ]) ] ] (q (empty_db ()) set_query) let test_q_builtin_range_values () = @@ -10181,19 +10181,19 @@ let test_q_builtin_range_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeEndValue (QValue (Int 3), "x") ] + ; where = [ RangeEndValue (QValue (Int64 3L), "x") ] } in assert_equal_query "q range expands a single positive end bound from zero" - [ [ Result_value (Int 0) ]; [ Result_value (Int 1) ]; [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 0L) ]; [ Result_value (Int64 1L) ]; [ Result_value (Int64 2L) ] ] (q (empty_db ()) end_query); let negative_end_query = { find = [ Find_var "x" ] ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeEndValue (QValue (Int (-2)), "x") ] + ; where = [ RangeEndValue (QValue (Int64 (-2L)), "x") ] } in assert_equal_query @@ -10205,19 +10205,19 @@ let test_q_builtin_range_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeValue (QValue (Int 1), QValue (Int 4), "x") ] + ; where = [ RangeValue (QValue (Int64 1L), QValue (Int64 4L), "x") ] } in assert_equal_query "q range expands an integer range into result rows" - [ [ Result_value (Int 1) ]; [ Result_value (Int 2) ]; [ Result_value (Int 3) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 2L) ]; [ Result_value (Int64 3L) ] ] (q (empty_db ()) query); let empty_query = { find = [ Find_var "x" ] ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeValue (QValue (Int 4), QValue (Int 1), "x") ] + ; where = [ RangeValue (QValue (Int64 4L), QValue (Int64 1L), "x") ] } in assert_equal_query @@ -10229,24 +10229,24 @@ let test_q_builtin_range_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeStepValue (QValue (Int 1), QValue (Int 8), QValue (Int 3), "x") ] + ; where = [ RangeStepValue (QValue (Int64 1L), QValue (Int64 8L), QValue (Int64 3L), "x") ] } in assert_equal_query "q range expands with a positive step" - [ [ Result_value (Int 1) ]; [ Result_value (Int 4) ]; [ Result_value (Int 7) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 4L) ]; [ Result_value (Int64 7L) ] ] (q (empty_db ()) stepped_query); let descending_query = { find = [ Find_var "x" ] ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeStepValue (QValue (Int 8), QValue (Int 1), QValue (Int (-3)), "x") ] + ; where = [ RangeStepValue (QValue (Int64 8L), QValue (Int64 1L), QValue (Int64 (-3L)), "x") ] } in assert_equal_query "q range expands with a negative step" - [ [ Result_value (Int 2) ]; [ Result_value (Int 5) ]; [ Result_value (Int 8) ] ] + [ [ Result_value (Int64 2L) ]; [ Result_value (Int64 5L) ]; [ Result_value (Int64 8L) ] ] (q (empty_db ()) descending_query); assert_raises_invalid_arg "q range rejects zero step" @@ -10258,15 +10258,15 @@ let test_q_builtin_range_values () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ RangeStepValue (QValue (Int 1), QValue (Int 4), QValue (Int 0), "x") ] + ; where = [ RangeStepValue (QValue (Int64 1L), QValue (Int64 4L), QValue (Int64 0L), "x") ] })) let test_q_builtin_tuple_and_untuple () = let tuple_query = { find = [ Find_var "pair" ] ; inputs = - [ Input_scalar ("a", Result_value (Int 1)) - ; Input_scalar ("b", Result_value (Int 2)) + [ Input_scalar ("a", Result_value (Int64 1L)) + ; Input_scalar ("b", Result_value (Int64 2L)) ] ; with_vars = [] ; rules = [] @@ -10275,7 +10275,7 @@ let test_q_builtin_tuple_and_untuple () = in assert_equal_query "q tuple builds a tuple value from bound terms" - [ [ Result_value (Tuple [ Some (Int 1); Some (Int 2) ]) ] ] + [ [ Result_value (Tuple [ Some (Int64 1L); Some (Int64 2L) ]) ] ] (q (empty_db ()) tuple_query); let untuple_query = { find = [ Find_var "b" ] @@ -10450,7 +10450,7 @@ let test_q_builtin_function_insufficient_bindings_match_upstream_messages () = (fun () -> ignore (q_string - ~inputs:[ Arg_collection [ Result_value (Int 1) ] ] + ~inputs:[ Arg_collection [ Result_value (Int64 1L) ] ] db "[:find ?e :in [?e ...] @@ -10461,7 +10461,7 @@ let test_q_builtin_function_insufficient_bindings_match_upstream_messages () = (fun () -> ignore (q_string - ~inputs:[ Arg_collection [ Result_value (Int 1) ] ] + ~inputs:[ Arg_collection [ Result_value (Int64 1L) ] ] db "[:find ?e ?x :in [?e ...] @@ -10554,8 +10554,8 @@ let test_q_not_insufficient_bindings_match_upstream_messages () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 20) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 20L) ] } ] in assert_raises_invalid_arg_message @@ -10585,9 +10585,9 @@ let test_q_not_join_projects_join_variables () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "artist", One_value (String "A"); "year", One_value (Int 1970) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "artist", One_value (String "A"); "year", One_value (Int 1971) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "artist", One_value (String "B"); "year", One_value (Int 1971) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "artist", One_value (String "A"); "year", One_value (Int64 1970L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "artist", One_value (String "A"); "year", One_value (Int64 1971L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "artist", One_value (String "B"); "year", One_value (Int64 1971L) ] } ] in let query = @@ -10600,7 +10600,7 @@ let test_q_not_join_projects_join_variables () = ; Pattern (QVar "release", QAttr "year", QVar "year") ; NotJoin ( [ "artist" ] - , [ Pattern (QVar "release", QAttr "year", QValue (Int 1970)) + , [ Pattern (QVar "release", QAttr "year", QValue (Int64 1970L)) ; Pattern (QVar "release", QAttr "artist", QVar "artist") ] ) @@ -10641,12 +10641,12 @@ let test_q_not_matches_upstream_edge_cases () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 20) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 20) ] } - ; Entity { db_id = Some (Entity_id 5); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 6); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 20) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 20L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 20L) ] } + ; Entity { db_id = Some (Entity_id 5); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 6); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 20L) ] } ] in assert_equal_query @@ -10786,7 +10786,7 @@ let test_q_or_allows_branch_vars_bound_by_outer_clauses () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 10) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 10L) ] } ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr") ] } ] in @@ -10798,7 +10798,7 @@ let test_q_or_allows_branch_vars_bound_by_outer_clauses () = ; where = [ Pattern (QVar "e", QAttr "name", QVar "name") ; Or - [ [ Pattern (QVar "e", QAttr "age", QValue (Int 10)) ] + [ [ Pattern (QVar "e", QAttr "age", QValue (Int64 10L)) ] ; [ Pattern (QVar "e", QAttr "name", QVar "name") ] ] ] @@ -10813,9 +10813,9 @@ let test_q_or_join_projects_join_variables () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "artist", One_value (String "A"); "year", One_value (Int 1970) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "artist", One_value (String "A"); "year", One_value (Int 1971) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "artist", One_value (String "B"); "year", One_value (Int 1971) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "artist", One_value (String "A"); "year", One_value (Int64 1970L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "artist", One_value (String "A"); "year", One_value (Int64 1971L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "artist", One_value (String "B"); "year", One_value (Int64 1971L) ] } ] in let query = @@ -10827,10 +10827,10 @@ let test_q_or_join_projects_join_variables () = [ Pattern (QVar "release", QAttr "artist", QVar "artist") ; OrJoin ( [ "artist" ] - , [ [ Pattern (QVar "release", QAttr "year", QValue (Int 1970)) + , [ [ Pattern (QVar "release", QAttr "year", QValue (Int64 1970L)) ; Pattern (QVar "release", QAttr "artist", QVar "artist") ] - ; [ Pattern (QVar "release", QAttr "year", QValue (Int 1972)) + ; [ Pattern (QVar "release", QAttr "year", QValue (Int64 1972L)) ; Pattern (QVar "release", QAttr "artist", QVar "artist") ] ] @@ -10874,7 +10874,7 @@ let test_q_or_join_rejects_branches_missing_unbound_listed_vars () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 10) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 10L) ] } ] in assert_raises_invalid_arg @@ -10952,16 +10952,16 @@ let test_q_or_join_required_vars_use_outer_bindings () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int 11) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int64 11L) ] } ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg") ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "age", One_value (Int 10); "name", One_value (String "Ivan") ] } - ; Entity { db_id = Some (Entity_id 5); attrs = [ "age", One_value (Int 11); "name", One_value (String "Oleg") ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "age", One_value (Int64 10L); "name", One_value (String "Ivan") ] } + ; Entity { db_id = Some (Entity_id 5); attrs = [ "age", One_value (Int64 11L); "name", One_value (String "Oleg") ] } ] in let query = { find = [ Find_var "e" ] - ; inputs = [ Input_scalar ("a", Result_value (Int 10)) ] + ; inputs = [ Input_scalar ("a", Result_value (Int64 10L)) ] ; with_vars = [] ; rules = [] ; where = @@ -11000,8 +11000,8 @@ let test_q_source_qualified_composite_clauses () = let ages = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int 20) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int64 20L) ] } ] in let source_not_query = @@ -11011,7 +11011,7 @@ let test_q_source_qualified_composite_clauses () = ; rules = [] ; where = [ SourcePattern ("names", QVar "e", QAttr "name", QWildcard) - ; SourceNot ("ages", [ Pattern (QVar "e", QAttr "age", QValue (Int 10)) ]) + ; SourceNot ("ages", [ Pattern (QVar "e", QAttr "age", QValue (Int64 10L)) ]) ] } in @@ -11028,8 +11028,8 @@ let test_q_source_qualified_composite_clauses () = [ SourcePattern ("names", QVar "e", QAttr "name", QWildcard) ; SourceOr ( "ages" - , [ [ Pattern (QVar "e", QAttr "age", QValue (Int 10)) ] - ; [ Pattern (QVar "e", QAttr "age", QValue (Int 20)) ] + , [ [ Pattern (QVar "e", QAttr "age", QValue (Int64 10L)) ] + ; [ Pattern (QVar "e", QAttr "age", QValue (Int64 20L)) ] ] ) ] @@ -11051,8 +11051,8 @@ let test_q_not_or_upstream_source_and_relation_batch () = let ages = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int 20) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "age", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "age", One_value (Int64 20L) ] } ] in assert_equal_query @@ -11180,7 +11180,7 @@ let test_q_with_entity_ref_inputs () = let db = empty_db ~schema:[ "name", unique_identity; "friend", ref_attr ] () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "friend", One_value (Ref 1) ] } ] in @@ -11194,7 +11194,7 @@ let test_q_with_entity_ref_inputs () = in assert_equal_query "q resolves lookup-ref scalar inputs for entity positions" - [ [ Result_value (Int 31) ] ] + [ [ Result_value (Int64 31L) ] ] (q db by_entity); let by_value = { find = [ Find_var "friend" ] @@ -11257,8 +11257,8 @@ let test_q_with_lookup_ref_inputs_in_entity_builtins () = let db = empty_db ~schema:[ "name", unique_identity ] () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 22); "height", One_value (Int 240) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 22L); "height", One_value (Int64 240L) ] } ] in let get_else_query = @@ -11295,7 +11295,7 @@ let test_q_with_lookup_ref_inputs_in_entity_builtins () = in assert_equal_query "q get-some resolves preserved lookup-ref scalar inputs" - [ [ Result_value (Ref_to (Lookup_ref ("name", String "Petr"))); Result_attr "age"; Result_value (Int 22) ] ] + [ [ Result_value (Ref_to (Lookup_ref ("name", String "Petr"))); Result_attr "age"; Result_value (Int64 22L) ] ] (q db get_some_query); let direct_get_some_query = { find = [ Find_var "person"; Find_var "attr"; Find_var "value" ] @@ -11307,7 +11307,7 @@ let test_q_with_lookup_ref_inputs_in_entity_builtins () = in assert_equal_query "q get-some resolves lookup-ref entity inputs like upstream issue-445" - [ [ Result_entity 2; Result_attr "age"; Result_value (Int 22) ] ] + [ [ Result_entity 2; Result_attr "age"; Result_value (Int64 22L) ] ] (q db direct_get_some_query) let test_q_with_relation_inputs () = @@ -11403,16 +11403,16 @@ let test_q_with_dynamic_callable_inputs () = |> db_with [ Entity { db_id = Some (Entity_id 1) - ; attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] + ; attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } ; Entity { db_id = Some (Entity_id 2) - ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 19) ] + ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 19L) ] } ] in let adult = function - | [ Result_value (Int age) ] -> age >= 21 + | [ Result_value (Int64 age) ] -> age >= 21L | _ -> false in assert_equal_query @@ -11442,7 +11442,7 @@ let test_q_with_dynamic_callable_inputs () = :where [?e :name ?name] [(?label-fn ?name) ?label]]"); let five = function - | [] -> Some [ Result_value (Int 5) ] + | [] -> Some [ Result_value (Int64 5L) ] | _ -> None in assert_equal_query @@ -11460,15 +11460,15 @@ let test_q_with_dynamic_callable_inputs () = "q_string skips dynamic predicates when their binding relation is empty like upstream issue-180" [] (q_string - (empty_db () |> db_with [ Add (Entity_id 1, "age", Int 20) ]) + (empty_db () |> db_with [ Add (Entity_id 1, "age", Int64 20L) ]) "[:find ?e ?age :where [_ :pred ?pred] [?e :age ?age] [(?pred ?age)]]"); let age_matches = function - | [ Result_db source_db; Result_entity entity_id; Result_value (Int expected_age) ] -> + | [ Result_db source_db; Result_entity entity_id; Result_value (Int64 expected_age) ] -> (match entity source_db (Entity_id entity_id) with - | Some entity -> entity_attr entity "age" = Some (One_value (Int expected_age)) + | Some entity -> entity_attr entity "age" = Some (One_value (Int64 expected_age)) | None -> false) | _ -> false in @@ -11496,26 +11496,26 @@ let test_q_with_dynamic_callable_inputs () = [$people ?e :age ?age] [(?age-matches $people ?e ?age)]]"); let range_values = function - | [ Result_value (Int min_value); Result_value (Int max_value) ] -> + | [ Result_value (Int64 min_value); Result_value (Int64 max_value) ] -> let rec collect value acc = if value >= max_value then List.rev acc - else collect (value + 1) (Int value :: acc) + else collect (Int64.add value 1L) (Int64 value :: acc) in Some [ Result_value (List (collect min_value [])) ] | _ -> None in assert_equal_query "q_string accepts dynamic function inputs with collection output bindings" - [ [ Result_value (Keyword "a"); Result_value (Int 2) ] - ; [ Result_value (Keyword "a"); Result_value (Int 4) ] - ; [ Result_value (Keyword "a"); Result_value (Int 6) ] - ; [ Result_value (Keyword "b"); Result_value (Int 2) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "a"); Result_value (Int64 4L) ] + ; [ Result_value (Keyword "a"); Result_value (Int64 6L) ] + ; [ Result_value (Keyword "b"); Result_value (Int64 2L) ] ] (q_string ~inputs: [ Arg_relation - [ [ Result_value (Keyword "a"); Result_value (List [ Int 1; Int 7 ]) ] - ; [ Result_value (Keyword "b"); Result_value (List [ Int 2; Int 4 ]) ] + [ [ Result_value (Keyword "a"); Result_value (List [ Int64 1L; Int64 7L ]) ] + ; [ Result_value (Keyword "b"); Result_value (List [ Int64 2L; Int64 4L ]) ] ] ; Arg_function range_values ] @@ -11551,21 +11551,21 @@ let test_q_with_dynamic_callable_inputs () = let test_q_nested_relation_map_inputs () = assert_equal_query "q_string supports queries with only scalar inputs and no db source" - [ [ Result_value (Int 10); Result_value (Int 20) ] ] + [ [ Result_value (Int64 10L); Result_value (Int64 20L) ] ] (q_string - ~inputs:[ Arg_scalar (Result_value (Int 10)); Arg_scalar (Result_value (Int 20)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 10L)); Arg_scalar (Result_value (Int64 20L)) ] (empty_db ()) "[:find ?a ?b :in ?a ?b]"); assert_equal_query "q_string binds plain map inputs as relation rows" - [ [ Result_value (Keyword "b"); Result_value (Int 2) ] - ; [ Result_value (Keyword "c"); Result_value (Int 3) ] + [ [ Result_value (Keyword "b"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "c"); Result_value (Int64 3L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value - (Map [ Keyword "a", Int 1; Keyword "b", Int 2; Keyword "c", Int 3 ])) + (Map [ Keyword "a", Int64 1L; Keyword "b", Int64 2L; Keyword "c", Int64 3L ])) ] (empty_db ()) "[:find ?k ?v @@ -11579,28 +11579,28 @@ let test_q_nested_relation_map_inputs () = let min_value, max_value = List.fold_left (fun (min_value, max_value) -> function - | Int value -> min min_value value, max max_value value + | Int64 value -> Int64.min min_value value, Int64.max max_value value | _ -> min_value, max_value) (match first with - | Int value -> value, value - | _ -> 0, 0) + | Int64 value -> value, value + | _ -> 0L, 0L) rest in - Some [ Result_value (Int min_value); Result_value (Int max_value) ]) + Some [ Result_value (Int64 min_value); Result_value (Int64 max_value) ]) | _ -> None in assert_equal_query "q_string binds map relation rows through dynamic tuple outputs" - [ [ Result_value (Keyword "a"); Result_value (Int 1); Result_value (Int 4) ] - ; [ Result_value (Keyword "b"); Result_value (Int 5); Result_value (Int 7) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 1L); Result_value (Int64 4L) ] + ; [ Result_value (Keyword "b"); Result_value (Int64 5L); Result_value (Int64 7L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", List [ Int 1; Int 2; Int 4 ] - ; Keyword "b", List [ Int 5; Int 7 ] + [ Keyword "a", List [ Int64 1L; Int64 2L; Int64 4L ] + ; Keyword "b", List [ Int64 5L; Int64 7L ] ])) ; Arg_function minmax ] @@ -11610,28 +11610,28 @@ let test_q_nested_relation_map_inputs () = :where [(?minmax ?v) [?min ?max]] [(> ?max ?min)]]"); let range_values = function - | [ Result_value (Int min_value); Result_value (Int max_value) ] -> + | [ Result_value (Int64 min_value); Result_value (Int64 max_value) ] -> let rec collect value acc = if value >= max_value then List.rev acc - else collect (value + 1) (Int value :: acc) + else collect (Int64.add value 1L) (Int64 value :: acc) in Some [ Result_value (List (collect min_value [])) ] | _ -> None in assert_equal_query "q_string binds nested map relation rows through dynamic collection outputs" - [ [ Result_value (Keyword "a"); Result_value (Int 2) ] - ; [ Result_value (Keyword "a"); Result_value (Int 4) ] - ; [ Result_value (Keyword "a"); Result_value (Int 6) ] - ; [ Result_value (Keyword "b"); Result_value (Int 2) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "a"); Result_value (Int64 4L) ] + ; [ Result_value (Keyword "a"); Result_value (Int64 6L) ] + ; [ Result_value (Keyword "b"); Result_value (Int64 2L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", List [ Int 1; Int 7 ] - ; Keyword "b", List [ Int 2; Int 4 ] + [ Keyword "a", List [ Int64 1L; Int64 7L ] + ; Keyword "b", List [ Int64 2L; Int64 4L ] ])) ; Arg_function range_values ] @@ -11642,17 +11642,17 @@ let test_q_nested_relation_map_inputs () = [(even? ?x)]]"); assert_equal_query "q_string binds map inputs as nested relation rows" - [ [ Result_value (Keyword "b"); Result_value (Int 2) ] - ; [ Result_value (Keyword "c"); Result_value (Int 3) ] + [ [ Result_value (Keyword "b"); Result_value (Int64 2L) ] + ; [ Result_value (Keyword "c"); Result_value (Int64 3L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ Keyword "a", List [ Int 1 ] - ; Keyword "b", List [ Int 2 ] - ; Keyword "c", List [ Int 3 ] + [ Keyword "a", List [ Int64 1L ] + ; Keyword "b", List [ Int64 2L ] + ; Keyword "c", List [ Int64 3L ] ])) ] (empty_db ()) @@ -11752,8 +11752,8 @@ let test_q_input_placeholders_ignore_values () = ; inputs = [ Input_relation ( [ "x"; "_"; "_"; "z" ] - , [ [ Result_value (Keyword "a"); Result_value (Int 1); Result_value (Int 2); Result_value (Keyword "b") ] - ; [ Result_value (Keyword "c"); Result_value (Int 3); Result_value (Int 4); Result_value (Keyword "d") ] + , [ [ Result_value (Keyword "a"); Result_value (Int64 1L); Result_value (Int64 2L); Result_value (Keyword "b") ] + ; [ Result_value (Keyword "c"); Result_value (Int64 3L); Result_value (Int64 4L); Result_value (Keyword "d") ] ] ) ] @@ -11773,8 +11773,8 @@ let test_q_return_shapes () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } ] in let query = @@ -11788,8 +11788,8 @@ let test_q_return_shapes () = if q_return db Return_relation query <> Query_relation - [ [ Result_value (String "Ivan"); Result_value (Int 31) ] - ; [ Result_value (String "Petr"); Result_value (Int 37) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 31L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 37L) ] ] then failwith "q_return relation should preserve q rows"; if @@ -11798,7 +11798,7 @@ let test_q_return_shapes () = then failwith "q_return collection should return first column values"; if q_return db Return_tuple query - <> Query_tuple (Some [ Result_value (String "Ivan"); Result_value (Int 31) ]) + <> Query_tuple (Some [ Result_value (String "Ivan"); Result_value (Int64 31L) ]) then failwith "q_return tuple should return first row"; if q_return db Return_scalar { query with find = [ Find_var "name" ] } @@ -11809,8 +11809,8 @@ let test_parse_query_return_shapes () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } ] in let collection_form = @@ -11902,30 +11902,30 @@ let test_parse_query_return_shapes () = [ QueryFormKeyword "find" ; QueryFormVector [ QueryFormSymbol "?name"; QueryFormSymbol "?age" ] ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "name"; QueryFormSymbol "?name" ] - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "age"; QueryFormSymbol "?age" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "name"; QueryFormSymbol "?name" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "age"; QueryFormSymbol "?age" ] ] in let return, query = parse_query_return tuple_form in if return <> Return_tuple then failwith "parse_query_return should detect find tuple"; if q_return db return query - <> Query_tuple (Some [ Result_value (String "Ivan"); Result_value (Int 31) ]) + <> Query_tuple (Some [ Result_value (String "Ivan"); Result_value (Int64 31L) ]) then failwith "parse_query_return tuple should produce tuple output"; let list_tuple_form = QueryFormVector [ QueryFormKeyword "find" ; QueryFormList [ QueryFormSymbol "?name"; QueryFormSymbol "?age" ] ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "name"; QueryFormSymbol "?name" ] - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "age"; QueryFormSymbol "?age" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "name"; QueryFormSymbol "?name" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "age"; QueryFormSymbol "?age" ] ] in let return, query = parse_query_return list_tuple_form in if return <> Return_tuple then failwith "parse_query_return should detect list-form find tuple"; if q_return db return query - <> Query_tuple (Some [ Result_value (String "Ivan"); Result_value (Int 31) ]) + <> Query_tuple (Some [ Result_value (String "Ivan"); Result_value (Int64 31L) ]) then failwith "parse_query_return list tuple should produce tuple output"; let scalar_form = QueryFormVector @@ -11933,7 +11933,7 @@ let test_parse_query_return_shapes () = ; QueryFormSymbol "?name" ; QueryFormSymbol "." ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "name"; QueryFormSymbol "?name" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "name"; QueryFormSymbol "?name" ] ] in let return, query = parse_query_return scalar_form in @@ -11953,24 +11953,24 @@ let test_parse_query_return_shapes () = in let return, query = parse_query_return aggregate_collection_form in if return <> Return_collection then failwith "parse_query_return should detect aggregate find collection"; - if q_return db return query <> Query_collection [ Result_value (Int 2) ] then + if q_return db return query <> Query_collection [ Result_value (Int64 2L) ] then failwith "parse_query_return aggregate collection should produce collection output"; if q_return_string db "[:find [(count ?name)] :where [_ :name ?name]]" - <> Query_tuple (Some [ Result_value (Int 2) ]) + <> Query_tuple (Some [ Result_value (Int64 2L) ]) then failwith "q_return_string aggregate tuple find spec should produce tuple output"; if q_return_string db "[:find (count ?name) . :where [_ :name ?name]]" - <> Query_scalar (Some (Result_value (Int 2))) + <> Query_scalar (Some (Result_value (Int64 2L))) then failwith "q_return_string aggregate scalar find spec should produce scalar output" let test_q_return_find_specs_match_upstream_cases () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 25) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Sergey"); "age", One_value (Int 11) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 25L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Sergey"); "age", One_value (Int64 11L) ] } ] in if @@ -11982,9 +11982,9 @@ let test_q_return_find_specs_match_upstream_cases () = ] then failwith "q_return_string collection find spec should return all names"; let expected_rows = - [ [ Result_value (String "Petr"); Result_value (Int 44) ] - ; [ Result_value (String "Ivan"); Result_value (Int 25) ] - ; [ Result_value (String "Sergey"); Result_value (Int 11) ] + [ [ Result_value (String "Petr"); Result_value (Int64 44L) ] + ; [ Result_value (String "Ivan"); Result_value (Int64 25L) ] + ; [ Result_value (String "Sergey"); Result_value (Int64 11L) ] ] in (match q_return_string db "[:find [?name ?age] :where [?e :name ?name] [?e :age ?age]]" with @@ -11999,23 +11999,23 @@ let test_q_return_find_specs_match_upstream_cases () = | _ -> failwith "scalar find spec should return one value"); if q_return_string db "[:find [(count ?name) ...] :where [_ :name ?name]]" - <> Query_collection [ Result_value (Int 3) ] + <> Query_collection [ Result_value (Int64 3L) ] then failwith "aggregate collection find spec should return aggregate value"; if q_return_string db "[:find [(count ?name)] :where [_ :name ?name]]" - <> Query_tuple (Some [ Result_value (Int 3) ]) + <> Query_tuple (Some [ Result_value (Int64 3L) ]) then failwith "aggregate tuple find spec should return aggregate value"; if q_return_string db "[:find (count ?name) . :where [_ :name ?name]]" - <> Query_scalar (Some (Result_value (Int 3))) + <> Query_scalar (Some (Result_value (Int64 3L))) then failwith "aggregate scalar find spec should return aggregate value" let test_q_return_map_shapes () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } ] in let query = @@ -12029,35 +12029,35 @@ let test_q_return_map_shapes () = if q_return_map db Return_relation (Return_keys [ "n"; "a" ]) query <> Query_relation_maps - [ [ Keyword "a", Result_value (Int 31); Keyword "n", Result_value (String "Ivan") ] - ; [ Keyword "a", Result_value (Int 37); Keyword "n", Result_value (String "Petr") ] + [ [ Keyword "a", Result_value (Int64 31L); Keyword "n", Result_value (String "Ivan") ] + ; [ Keyword "a", Result_value (Int64 37L); Keyword "n", Result_value (String "Petr") ] ] then failwith "q_return_map relation should map rows by labels"; if q_return_map db Return_relation (Return_syms [ "n"; "a" ]) query <> Query_relation_maps - [ [ Symbol "a", Result_value (Int 31); Symbol "n", Result_value (String "Ivan") ] - ; [ Symbol "a", Result_value (Int 37); Symbol "n", Result_value (String "Petr") ] + [ [ Symbol "a", Result_value (Int64 31L); Symbol "n", Result_value (String "Ivan") ] + ; [ Symbol "a", Result_value (Int64 37L); Symbol "n", Result_value (String "Petr") ] ] then failwith "q_return_map relation should support :syms labels"; if q_return_map db Return_relation (Return_strs [ "n"; "a" ]) query <> Query_relation_maps - [ [ String "a", Result_value (Int 31); String "n", Result_value (String "Ivan") ] - ; [ String "a", Result_value (Int 37); String "n", Result_value (String "Petr") ] + [ [ String "a", Result_value (Int64 31L); String "n", Result_value (String "Ivan") ] + ; [ String "a", Result_value (Int64 37L); String "n", Result_value (String "Petr") ] ] then failwith "q_return_map relation should support :strs labels"; if q_return_map db Return_tuple (Return_strs [ "name"; "age" ]) query - <> Query_tuple_map (Some [ String "age", Result_value (Int 31); String "name", Result_value (String "Ivan") ]) + <> Query_tuple_map (Some [ String "age", Result_value (Int64 31L); String "name", Result_value (String "Ivan") ]) then failwith "q_return_map tuple should map the first row by labels"; if q_return_map db Return_tuple (Return_syms [ "name"; "age" ]) query - <> Query_tuple_map (Some [ Symbol "age", Result_value (Int 31); Symbol "name", Result_value (String "Ivan") ]) + <> Query_tuple_map (Some [ Symbol "age", Result_value (Int64 31L); Symbol "name", Result_value (String "Ivan") ]) then failwith "q_return_map :syms should preserve symbol labels"; if q_return_map_string db "[:find [?name ?age] :syms name age :where [1 :name ?name] [1 :age ?age]]" - <> Query_tuple_map (Some [ Symbol "age", Result_value (Int 31); Symbol "name", Result_value (String "Ivan") ]) + <> Query_tuple_map (Some [ Symbol "age", Result_value (Int64 31L); Symbol "name", Result_value (String "Ivan") ]) then failwith "q_return_map_string :syms should parse symbol labels"; assert_raises_invalid_arg "q_return_map rejects mismatched label count" @@ -12070,16 +12070,16 @@ let test_q_return_map_string_upstream_shape_batch () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 25) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Sergey"); "age", One_value (Int 11) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 25L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Sergey"); "age", One_value (Int64 11L) ] } ] in let expected_keys = Query_relation_maps - [ [ Keyword "a", Result_value (Int 25); Keyword "n", Result_value (String "Ivan") ] - ; [ Keyword "a", Result_value (Int 44); Keyword "n", Result_value (String "Petr") ] - ; [ Keyword "a", Result_value (Int 11); Keyword "n", Result_value (String "Sergey") ] + [ [ Keyword "a", Result_value (Int64 25L); Keyword "n", Result_value (String "Ivan") ] + ; [ Keyword "a", Result_value (Int64 44L); Keyword "n", Result_value (String "Petr") ] + ; [ Keyword "a", Result_value (Int64 11L); Keyword "n", Result_value (String "Sergey") ] ] in if @@ -12093,9 +12093,9 @@ let test_q_return_map_string_upstream_shape_batch () = then failwith "q_return_map_string should execute upstream :keys relation maps"; let expected_syms = Query_relation_maps - [ [ Symbol "a", Result_value (Int 25); Symbol "n", Result_value (String "Ivan") ] - ; [ Symbol "a", Result_value (Int 44); Symbol "n", Result_value (String "Petr") ] - ; [ Symbol "a", Result_value (Int 11); Symbol "n", Result_value (String "Sergey") ] + [ [ Symbol "a", Result_value (Int64 25L); Symbol "n", Result_value (String "Ivan") ] + ; [ Symbol "a", Result_value (Int64 44L); Symbol "n", Result_value (String "Petr") ] + ; [ Symbol "a", Result_value (Int64 11L); Symbol "n", Result_value (String "Sergey") ] ] in if @@ -12109,9 +12109,9 @@ let test_q_return_map_string_upstream_shape_batch () = then failwith "q_return_map_string should execute upstream :syms relation maps"; let expected_strs = Query_relation_maps - [ [ String "a", Result_value (Int 25); String "n", Result_value (String "Ivan") ] - ; [ String "a", Result_value (Int 44); String "n", Result_value (String "Petr") ] - ; [ String "a", Result_value (Int 11); String "n", Result_value (String "Sergey") ] + [ [ String "a", Result_value (Int64 25L); String "n", Result_value (String "Ivan") ] + ; [ String "a", Result_value (Int64 44L); String "n", Result_value (String "Petr") ] + ; [ String "a", Result_value (Int64 11L); String "n", Result_value (String "Sergey") ] ] in if @@ -12131,15 +12131,15 @@ let test_q_return_map_string_upstream_shape_batch () = :where [?e :name ?name] [(= ?name \"Ivan\")] [?e :age ?age]]" - <> Query_tuple_map (Some [ Keyword "a", Result_value (Int 25); Keyword "n", Result_value (String "Ivan") ]) + <> Query_tuple_map (Some [ Keyword "a", Result_value (Int64 25L); Keyword "n", Result_value (String "Ivan") ]) then failwith "q_return_map_string should execute upstream tuple :keys maps" let test_parse_query_return_map_shapes () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } ] in let keys_form = @@ -12162,8 +12162,8 @@ let test_parse_query_return_map_shapes () = if q_return_map db return (Option.get return_map) query <> Query_relation_maps - [ [ Keyword "a", Result_value (Int 31); Keyword "n", Result_value (String "Ivan") ] - ; [ Keyword "a", Result_value (Int 37); Keyword "n", Result_value (String "Petr") ] + [ [ Keyword "a", Result_value (Int64 31L); Keyword "n", Result_value (String "Ivan") ] + ; [ Keyword "a", Result_value (Int64 37L); Keyword "n", Result_value (String "Petr") ] ] then failwith "parsed :keys query should produce relation maps"; let tuple_form = @@ -12174,8 +12174,8 @@ let test_parse_query_return_map_shapes () = ; QueryFormSymbol "name" ; QueryFormSymbol "age" ; QueryFormKeyword "where" - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "name"; QueryFormSymbol "?name" ] - ; QueryFormVector [ QueryFormInt 1; QueryFormKeyword "age"; QueryFormSymbol "?age" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "name"; QueryFormSymbol "?name" ] + ; QueryFormVector [ QueryFormInt 1L; QueryFormKeyword "age"; QueryFormSymbol "?age" ] ] in let return, return_map, query = parse_query_return_map tuple_form in @@ -12184,7 +12184,7 @@ let test_parse_query_return_map_shapes () = failwith "parse_query_return_map should parse :strs labels"; if q_return_map db return (Option.get return_map) query - <> Query_tuple_map (Some [ String "age", Result_value (Int 31); String "name", Result_value (String "Ivan") ]) + <> Query_tuple_map (Some [ String "age", Result_value (Int64 31L); String "name", Result_value (String "Ivan") ]) then failwith "parsed :strs tuple query should produce a tuple map"; assert_raises_invalid_arg "parse_query_return_map rejects multiple return map clauses" @@ -12283,7 +12283,7 @@ let test_parse_query_resolves_lookup_refs_in_patterns () = |> db_with [ Entity { db_id = Some (Entity_id 1) - ; attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 31) ] + ; attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 31L) ] } ; Entity { db_id = Some (Entity_id 2) @@ -12305,7 +12305,7 @@ let test_parse_query_resolves_lookup_refs_in_patterns () = in assert_equal_query "parse_query resolves lookup refs in entity position" - [ [ Result_value (Int 31) ] ] + [ [ Result_value (Int64 31L) ] ] (q db (parse_query entity_lookup_query)); let ref_value_lookup_query = QueryFormVector @@ -12341,7 +12341,7 @@ let test_parse_query_resolves_lookup_refs_in_patterns () = in assert_equal_query "parse_query resolves source-qualified lookup refs" - [ [ Result_value (Int 31) ] ] + [ [ Result_value (Int64 31L) ] ] (q_sources (empty_db ()) [ "people", Db_source db ] (parse_query source_lookup_query)) let test_q_with_multiple_sources () = @@ -12355,8 +12355,8 @@ let test_q_with_multiple_sources () = let db2 = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 10); attrs = [ "email", One_value (String "ivan@example.com"); "score", One_value (Int 7) ] } - ; Entity { db_id = Some (Entity_id 11); attrs = [ "email", One_value (String "olga@example.com"); "score", One_value (Int 9) ] } + [ Entity { db_id = Some (Entity_id 10); attrs = [ "email", One_value (String "ivan@example.com"); "score", One_value (Int64 7L) ] } + ; Entity { db_id = Some (Entity_id 11); attrs = [ "email", One_value (String "olga@example.com"); "score", One_value (Int64 9L) ] } ] in let query = @@ -12374,7 +12374,7 @@ let test_q_with_multiple_sources () = in assert_equal_query "q_sources joins facts across named database sources" - [ [ Result_value (String "Ivan"); Result_value (Int 7) ] ] + [ [ Result_value (String "Ivan"); Result_value (Int64 7L) ] ] (q_sources db1 [ "scores", Db_source db2 ] query) let test_q_with_relation_source () = @@ -12479,10 +12479,10 @@ let test_q_sources_default_source () = in assert_equal_query "q_sources allows relation sources to override the default source" - [ [ Result_value (Int 1) ]; [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 2L) ] ] (q_sources (empty_db ()) - [ "$", Relation_source [ [ Result_value (Int 1) ]; [ Result_value (Int 2) ] ] ] + [ "$", Relation_source [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 2L) ] ] ] (parse_query relation_query)); let unqualified_relation_query = QueryFormVector @@ -12496,10 +12496,10 @@ let test_q_sources_default_source () = in assert_equal_query "parse_query matches unqualified one-column patterns against default relation sources" - [ [ Result_value (Int 1) ]; [ Result_value (Int 2) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 2L) ] ] (q_sources (empty_db ()) - [ "$", Relation_source [ [ Result_value (Int 1) ]; [ Result_value (Int 2) ] ] ] + [ "$", Relation_source [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 2L) ] ] ] (parse_query unqualified_relation_query)); let unqualified_three_column_relation_query = QueryFormVector @@ -12549,26 +12549,26 @@ let test_q_sources_default_source () = in assert_equal_query "parse_query matches long relation tuples with constant trailing terms" - [ [ Result_value (Int 1) + [ [ Result_value (Int64 1L) ; Result_attr "age" - ; Result_value (Int 39) - ; Result_value (Int 999) + ; Result_value (Int64 39L) + ; Result_value (Int64 999L) ] ] (q_sources (empty_db ()) [ ( "$" , Relation_source - [ [ Result_value (Int 1) + [ [ Result_value (Int64 1L) ; Result_attr "name" ; Result_value (String "Ivan") - ; Result_value (Int 945) + ; Result_value (Int64 945L) ; Result_value (Keyword "db/add") ] - ; [ Result_value (Int 1) + ; [ Result_value (Int64 1L) ; Result_attr "age" - ; Result_value (Int 39) - ; Result_value (Int 999) + ; Result_value (Int64 39L) + ; Result_value (Int64 999L) ; Result_value (Keyword "db/retract") ] ] ) @@ -12587,21 +12587,21 @@ let test_q_sources_default_source () = in assert_equal_query "parse_query matches shorter patterns against long relation tuple prefixes" - [ [ Result_value (Int 1); Result_value (String "Ivan") ] ] + [ [ Result_value (Int64 1L); Result_value (String "Ivan") ] ] (q_sources (empty_db ()) [ ( "$" , Relation_source - [ [ Result_value (Int 1) + [ [ Result_value (Int64 1L) ; Result_attr "name" ; Result_value (String "Ivan") - ; Result_value (Int 945) + ; Result_value (Int64 945L) ; Result_value (Keyword "db/add") ] - ; [ Result_value (Int 1) + ; [ Result_value (Int64 1L) ; Result_attr "age" - ; Result_value (Int 39) - ; Result_value (Int 999) + ; Result_value (Int64 39L) + ; Result_value (Int64 999L) ; Result_value (Keyword "db/retract") ] ] ) @@ -12631,7 +12631,7 @@ let test_q_sources_default_source () = [ [ Result_value (String "Ivan") ] ] (q_sources (empty_db ()) [ "$", Db_source override_db ] (parse_query tx_query)); let lookup_db = - override_db |> db_with [ Add (Entity_id 1, "height", Int 180) ] + override_db |> db_with [ Add (Entity_id 1, "height", Int64 180L) ] in let get_else_query = QueryFormVector @@ -12646,7 +12646,7 @@ let test_q_sources_default_source () = [ QueryFormSymbol "get-else" ; QueryFormSymbol "?e" ; QueryFormKeyword "height" - ; QueryFormInt 300 + ; QueryFormInt 300L ] ; QueryFormSymbol "?height" ] @@ -12654,7 +12654,7 @@ let test_q_sources_default_source () = in assert_equal_query "parse_query unqualified get-else uses the overridden default source" - [ [ Result_value (Int 180) ] ] + [ [ Result_value (Int64 180L) ] ] (q_sources (empty_db ()) [ "$", Db_source lookup_db ] (parse_query get_else_query)); let get_some_query = QueryFormVector @@ -12678,7 +12678,7 @@ let test_q_sources_default_source () = in assert_equal_query "parse_query unqualified get-some uses the overridden default source" - [ [ Result_attr "height"; Result_value (Int 180) ] ] + [ [ Result_attr "height"; Result_value (Int64 180L) ] ] (q_sources (empty_db ()) [ "$", Db_source lookup_db ] (parse_query get_some_query)); let missing_query = QueryFormVector @@ -12751,7 +12751,7 @@ let test_q_sources_lookup_ref_uses_named_source () = let source = empty_db ~schema:[ "email", unique_identity ] () |> db_with - [ Entity { db_id = Some (Entity_id 10); attrs = [ "email", One_value (String "ivan@example.com"); "score", One_value (Int 7) ] } + [ Entity { db_id = Some (Entity_id 10); attrs = [ "email", One_value (String "ivan@example.com"); "score", One_value (Int64 7L) ] } ] in let query = @@ -12764,7 +12764,7 @@ let test_q_sources_lookup_ref_uses_named_source () = in assert_equal_query "q_sources resolves lookup refs against the named source" - [ [ Result_value (Int 7) ] ] + [ [ Result_value (Int64 7L) ] ] (q_sources db [ "scores", Db_source source ] query) let test_q_resolves_idents_in_patterns () = @@ -12878,9 +12878,9 @@ let test_q_return_shapes_with_pull_expressions () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 25) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 11) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 25L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 11L) ] } ] in let pulled_ivan = @@ -12891,7 +12891,7 @@ let test_q_return_shapes_with_pull_expressions () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ Pattern (QVar "e", QAttr "age", QValue (Int 25)) ] + ; where = [ Pattern (QVar "e", QAttr "age", QValue (Int64 25L)) ] } in if q_return db Return_scalar scalar_query <> Query_scalar (Some pulled_ivan) then @@ -12912,7 +12912,7 @@ let test_q_return_shapes_with_pull_expressions () = ; inputs = [] ; with_vars = [] ; rules = [] - ; where = [ Pattern (QVar "e", QAttr "age", QValue (Int 25)) ] + ; where = [ Pattern (QVar "e", QAttr "age", QValue (Int64 25L)) ] } in if q_return db Return_tuple tuple_query <> Query_tuple (Some [ Result_entity 2; pulled_ivan ]) then @@ -12947,9 +12947,9 @@ let test_q_with_aggregates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "blue"); "heads", One_value (Int 2) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "blue"); "heads", One_value (Int64 2L) ] } ] in let query = @@ -12971,8 +12971,8 @@ let test_q_with_aggregates () = in assert_equal_query "q aggregates group by non-aggregate find vars" - [ [ Result_value (String "blue"); Result_value (Int 2); Result_value (Int 2); Result_value (Int 2); Result_value (Int 1) ] - ; [ Result_value (String "red"); Result_value (Int 4); Result_value (Int 1); Result_value (Int 3); Result_value (Int 2) ] + [ [ Result_value (String "blue"); Result_value (Int64 2L); Result_value (Int64 2L); Result_value (Int64 2L); Result_value (Int64 1L) ] + ; [ Result_value (String "red"); Result_value (Int64 4L); Result_value (Int64 1L); Result_value (Int64 3L); Result_value (Int64 2L) ] ] (q db query) @@ -12984,19 +12984,19 @@ let test_q_aggregates_with_pull_expressions () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Petr") - ; "value", Many_values [ Int 10; Int 20; Int 30; Int 40 ] + ; "value", Many_values [ Int64 10L; Int64 20L; Int64 30L; Int64 40L ] ] } ; Entity { db_id = Some (Entity_id 2) ; attrs = [ "name", One_value (String "Ivan") - ; "value", Many_values [ Int 14; Int 16 ] + ; "value", Many_values [ Int64 14L; Int64 16L ] ] } ; Entity { db_id = Some (Entity_id 3) - ; attrs = [ "name", One_value (String "Oleg"); "value", One_value (Int 1) ] + ; attrs = [ "name", One_value (String "Oleg"); "value", One_value (Int64 1L) ] } ] in @@ -13017,18 +13017,18 @@ let test_q_aggregates_with_pull_expressions () = "q aggregates can be combined with pull expressions" [ [ Result_entity 1 ; Result_pull { pulled_id = 1; pulled_attrs = [ Keyword "name", Pulled_scalar (String "Petr") ] } - ; Result_value (Int 10) - ; Result_value (Int 40) + ; Result_value (Int64 10L) + ; Result_value (Int64 40L) ] ; [ Result_entity 2 ; Result_pull { pulled_id = 2; pulled_attrs = [ Keyword "name", Pulled_scalar (String "Ivan") ] } - ; Result_value (Int 14) - ; Result_value (Int 16) + ; Result_value (Int64 14L) + ; Result_value (Int64 16L) ] ; [ Result_entity 3 ; Result_pull { pulled_id = 3; pulled_attrs = [ Keyword "name", Pulled_scalar (String "Oleg") ] } - ; Result_value (Int 1) - ; Result_value (Int 1) + ; Result_value (Int64 1L) + ; Result_value (Int64 1L) ] ] (q db query) @@ -13037,9 +13037,9 @@ let test_q_with_interleaved_aggregates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "blue"); "heads", One_value (Int 2) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "blue"); "heads", One_value (Int64 2L) ] } ] in let query = @@ -13055,17 +13055,17 @@ let test_q_with_interleaved_aggregates () = in assert_equal_query "q preserves interleaved aggregate find order" - [ [ Result_value (Int 1); Result_value (String "blue"); Result_value (Int 2) ] - ; [ Result_value (Int 2); Result_value (String "red"); Result_value (Int 4) ] + [ [ Result_value (Int64 1L); Result_value (String "blue"); Result_value (Int64 2L) ] + ; [ Result_value (Int64 2L); Result_value (String "red"); Result_value (Int64 4L) ] ] (q db query) let test_q_aggregates_relation_inputs_with_with_vars () = let monsters = - [ [ Result_value (String "Cerberus"); Result_value (Int 3) ] - ; [ Result_value (String "Medusa"); Result_value (Int 1) ] - ; [ Result_value (String "Cyclops"); Result_value (Int 1) ] - ; [ Result_value (String "Chimera"); Result_value (Int 1) ] + [ [ Result_value (String "Cerberus"); Result_value (Int64 3L) ] + ; [ Result_value (String "Medusa"); Result_value (Int64 1L) ] + ; [ Result_value (String "Cyclops"); Result_value (Int64 1L) ] + ; [ Result_value (String "Chimera"); Result_value (Int64 1L) ] ] in let relation_input = Input_relation ([ "monster"; "heads" ], monsters) in @@ -13079,7 +13079,7 @@ let test_q_aggregates_relation_inputs_with_with_vars () = in assert_equal_query "q aggregate relation inputs deduplicate values without with vars" - [ [ Result_value (Int 4) ] ] + [ [ Result_value (Int64 4L) ] ] (q_with (empty_db ()) [] sum_query); let multi_aggregate_query = { find = @@ -13097,11 +13097,11 @@ let test_q_aggregates_relation_inputs_with_with_vars () = in assert_equal_query "q aggregate relation inputs preserve with-var-distinguished rows" - [ [ Result_value (Int 6) - ; Result_value (Int 1) - ; Result_value (Int 3) - ; Result_value (Int 4) - ; Result_value (Int 2) + [ [ Result_value (Int64 6L) + ; Result_value (Int64 1L) + ; Result_value (Int64 3L) + ; Result_value (Int64 4L) + ; Result_value (Int64 2L) ] ] (q_with (empty_db ()) [ "monster" ] multi_aggregate_query) @@ -13110,9 +13110,9 @@ let test_q_with_preserves_non_aggregate_duplicates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "monster", One_value (String "Medusa"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "monster", One_value (String "Cyclops"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "monster", One_value (String "Chimera"); "heads", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "monster", One_value (String "Medusa"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "monster", One_value (String "Cyclops"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "monster", One_value (String "Chimera"); "heads", One_value (Int64 1L) ] } ] in let query = @@ -13128,20 +13128,20 @@ let test_q_with_preserves_non_aggregate_duplicates () = in assert_equal_query "q without with vars deduplicates non-aggregate rows" - [ [ Result_value (Int 1) ] ] + [ [ Result_value (Int64 1L) ] ] (q_with db [] query); assert_equal_query "q_with preserves non-aggregate duplicates distinguished by with vars" - [ [ Result_value (Int 1) ]; [ Result_value (Int 1) ]; [ Result_value (Int 1) ] ] + [ [ Result_value (Int64 1L) ]; [ Result_value (Int64 1L) ]; [ Result_value (Int64 1L) ] ] (q_with db [ "monster" ] query) let test_q_count_distinct_aggregate () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 1L) ] } ] in let query = @@ -13157,16 +13157,16 @@ let test_q_count_distinct_aggregate () = in assert_equal_query "q count-distinct aggregates unique values within each group" - [ [ Result_value (String "red"); Result_value (Int 3); Result_value (Int 2) ] ] + [ [ Result_value (String "red"); Result_value (Int64 3L); Result_value (Int64 2L) ] ] (q db query) let test_q_distinct_aggregate () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 1L) ] } ] in let query = @@ -13182,7 +13182,7 @@ let test_q_distinct_aggregate () = in assert_equal_query "q distinct aggregate returns unique values as a set" - [ [ Result_value (String "red"); Result_value (Set [ Int 1; Int 3 ]) ] ] + [ [ Result_value (String "red"); Result_value (Set [ Int64 1L; Int64 3L ]) ] ] (q db query) let test_q_min_max_use_keyword_comparator () = @@ -13218,9 +13218,9 @@ let test_q_with_vars_preserve_aggregate_duplicates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 1L) ] } ] in let query = @@ -13236,20 +13236,20 @@ let test_q_with_vars_preserve_aggregate_duplicates () = in assert_equal_query "q_with without with vars deduplicates aggregate input tuples" - [ [ Result_value (String "red"); Result_value (Int 2) ] ] + [ [ Result_value (String "red"); Result_value (Int64 2L) ] ] (q_with db [] query); assert_equal_query "q_with preserves duplicates distinguished by with vars" - [ [ Result_value (String "red"); Result_value (Int 3) ] ] + [ [ Result_value (String "red"); Result_value (Int64 3L) ] ] (q_with db [ "e" ] query) let test_q_avg_aggregate () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 2) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int 3) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 2L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "heads", One_value (Int64 3L) ] } ] in let query = @@ -13272,7 +13272,7 @@ let test_q_sum_aggregate_accepts_float_values () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "amount", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "amount", One_value (Int64 1L) ] } ; Entity { db_id = Some (Entity_id 2); attrs = [ "amount", One_value (Float 2.5) ] } ] in @@ -13293,11 +13293,11 @@ let test_q_statistical_aggregates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "sample", One_value (Int 10) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "sample", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "sample", One_value (Int 20) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "sample", One_value (Int 35) ] } - ; Entity { db_id = Some (Entity_id 5); attrs = [ "sample", One_value (Int 75) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "sample", One_value (Int64 10L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "sample", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "sample", One_value (Int64 20L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "sample", One_value (Int64 35L) ] } + ; Entity { db_id = Some (Entity_id 5); attrs = [ "sample", One_value (Int64 75L) ] } ] in let query = @@ -13325,12 +13325,12 @@ let test_q_min_n_and_max_n_aggregates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 2) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 4) ] } - ; Entity { db_id = Some (Entity_id 5); attrs = [ "color", One_value (String "blue"); "amount", One_value (Int 7) ] } - ; Entity { db_id = Some (Entity_id 6); attrs = [ "color", One_value (String "blue"); "amount", One_value (Int 8) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 2L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 4L) ] } + ; Entity { db_id = Some (Entity_id 5); attrs = [ "color", One_value (String "blue"); "amount", One_value (Int64 7L) ] } + ; Entity { db_id = Some (Entity_id 6); attrs = [ "color", One_value (String "blue"); "amount", One_value (Int64 8L) ] } ] in let query = @@ -13347,18 +13347,18 @@ let test_q_min_n_and_max_n_aggregates () = assert_equal_query "q supports min n and max n aggregates" [ [ Result_value (String "blue") - ; Result_value (Tuple [ Some (Int 7); Some (Int 8) ]) - ; Result_value (Tuple [ Some (Int 7); Some (Int 8) ]) + ; Result_value (Tuple [ Some (Int64 7L); Some (Int64 8L) ]) + ; Result_value (Tuple [ Some (Int64 7L); Some (Int64 8L) ]) ] ; [ Result_value (String "red") - ; Result_value (Tuple [ Some (Int 2); Some (Int 3); Some (Int 4) ]) - ; Result_value (Tuple [ Some (Int 1); Some (Int 2); Some (Int 3) ]) + ; Result_value (Tuple [ Some (Int64 2L); Some (Int64 3L); Some (Int64 4L) ]) + ; Result_value (Tuple [ Some (Int64 1L); Some (Int64 2L); Some (Int64 3L) ]) ] ] (q db query) let test_q_rand_and_sample_aggregates () = - let values = [ Int 1; Int 2; Int 3 ] in + let values = [ Int64 1L; Int64 2L; Int64 3L ] in let member value = List.mem value values in let query = { find = @@ -13392,10 +13392,10 @@ let test_q_custom_aggregates () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 2) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "amount", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 4); attrs = [ "color", One_value (String "blue"); "amount", One_value (Int 5) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 2L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "color", One_value (String "red"); "amount", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 4); attrs = [ "color", One_value (String "blue"); "amount", One_value (Int64 5L) ] } ] in let reverse_tuple values = @@ -13420,14 +13420,14 @@ let test_q_custom_aggregates () = in assert_equal_query "q supports custom aggregate functions" - [ [ Result_value (String "blue"); Result_value (Tuple [ Some (Int 5) ]) ] - ; [ Result_value (String "red"); Result_value (Tuple [ Some (Int 3); Some (Int 2); Some (Int 1) ]) ] + [ [ Result_value (String "blue"); Result_value (Tuple [ Some (Int64 5L) ]) ] + ; [ Result_value (String "red"); Result_value (Tuple [ Some (Int64 3L); Some (Int64 2L); Some (Int64 1L) ]) ] ] (q db query); assert_equal_query "q_string parses custom aggregate inputs" - [ [ Result_value (String "blue"); Result_value (Tuple [ Some (Int 5) ]) ] - ; [ Result_value (String "red"); Result_value (Tuple [ Some (Int 3); Some (Int 2); Some (Int 1) ]) ] + [ [ Result_value (String "blue"); Result_value (Tuple [ Some (Int64 5L) ]) ] + ; [ Result_value (String "red"); Result_value (Tuple [ Some (Int64 3L); Some (Int64 2L); Some (Int64 1L) ]) ] ] (q_string ~inputs:[ Arg_aggregate reverse_tuple ] @@ -13443,23 +13443,23 @@ let test_q_custom_aggregates () = "[:find (aggregate ?agg ?amount) . :in $ ?agg :where [?e :amount ?amount]]" - <> Query_scalar (Some (Result_value (Tuple [ Some (Int 5); Some (Int 3); Some (Int 2); Some (Int 1) ]))) + <> Query_scalar (Some (Result_value (Tuple [ Some (Int64 5L); Some (Int64 3L); Some (Int64 2L); Some (Int64 1L) ]))) then failwith "q_return_string should parse scalar custom aggregate inputs"; let scaled_sum = function - | Result_value (Int factor) :: values -> + | Result_value (Int64 factor) :: values -> values |> List.fold_left (fun total -> function - | Result_value (Int value) -> total + value + | Result_value (Int64 value) -> Int64.add total value | _ -> invalid_arg "expected integer aggregate values") - 0 - |> fun total -> Result_value (Int (factor * total)) + 0L + |> fun total -> Result_value (Int64 (Int64.mul factor total)) | _ -> invalid_arg "expected integer aggregate factor" in assert_equal_query "q_string passes extra custom aggregate arguments before grouped values" - [ [ Result_value (String "blue"); Result_value (Int 50) ] - ; [ Result_value (String "red"); Result_value (Int 60) ] + [ [ Result_value (String "blue"); Result_value (Int64 50L) ] + ; [ Result_value (String "red"); Result_value (Int64 60L) ] ] (q_string ~inputs:[ Arg_aggregate scaled_sum ] @@ -13470,12 +13470,12 @@ let test_q_custom_aggregates () = [?e :amount ?amount]]"); if q_return_string - ~inputs:[ Arg_aggregate scaled_sum; Arg_scalar (Result_value (Int 2)) ] + ~inputs:[ Arg_aggregate scaled_sum; Arg_scalar (Result_value (Int64 2L)) ] db "[:find (aggregate ?agg ?factor ?amount) . :in $ ?agg ?factor :where [?e :amount ?amount]]" - <> Query_scalar (Some (Result_value (Int 22))) + <> Query_scalar (Some (Result_value (Int64 22L))) then failwith "q_return_string should pass variable aggregate arguments" let test_q_rejects_unknown_rules () = @@ -13820,13 +13820,13 @@ let test_q_source_qualified_rules () = let ages = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 10); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 15) ] } - ; Entity { db_id = Some (Entity_id 11); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 66) ] } - ; Entity { db_id = Some (Entity_id 12); attrs = [ "name", One_value (String "Darya"); "age", One_value (Int 32) ] } + [ Entity { db_id = Some (Entity_id 10); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 15L) ] } + ; Entity { db_id = Some (Entity_id 11); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 66L) ] } + ; Entity { db_id = Some (Entity_id 12); attrs = [ "name", One_value (String "Darya"); "age", One_value (Int64 32L) ] } ] in let adult = function - | [ Result_value (Int age) ] -> age >= 18 + | [ Result_value (Int64 age) ] -> age >= 18L | _ -> false in let query = @@ -13927,9 +13927,9 @@ let test_query_fns__test_predicates () = let test_query_fns__test_symbol_resolution () = assert_equal_query "query_fns.cljc test-symbol-resolution resolves a callable query function" - [ [ Result_value (Int 42) ] ] + [ [ Result_value (Int64 42L) ] ] (q_string - ~inputs:[ Arg_function (fun _ -> Some [ Result_value (Int 42) ]) ] + ~inputs:[ Arg_function (fun _ -> Some [ Result_value (Int64 42L) ]) ] (empty_db ()) "[:find ?x :in ?f @@ -14025,7 +14025,7 @@ let test_query_rules__test_rule_performance_on_larger_datasets () = Entity { db_id = Some (Entity_id eid) ; attrs = - [ "item/id", One_value (Int eid) + [ "item/id", One_value (Int64 (Int64.of_int eid)) ; "item/status", One_value (String (status_for eid)) ] })) @@ -14174,13 +14174,13 @@ let test_transact__test_tempid_ref_issue_295 () = [ Entity { db_id = Some (Temp_id "user"); attrs = [ "name", One_value (String "Alice") ] } ; Entity { db_id = None - ; attrs = [ "age", One_value (Int 36); "ref", One_value (Ref_to (Temp_id "user")) ] + ; attrs = [ "age", One_value (Int64 36L); "ref", One_value (Ref_to (Temp_id "user")) ] } ] in assert_equal_triples "entity map tempid upsert remaps later ref values" - [ 1, "name", String "Alice"; 2, "age", Int 36; 2, "ref", Ref 1 ] + [ 1, "name", String "Alice"; 2, "age", Int64 36L; 2, "ref", Ref 1 ] (datoms report.db_after Eavt ()); assert_equal_tempids "entity map tempid resolves to existing unique identity entity" @@ -14360,17 +14360,17 @@ let test_transact__test_transient_issue_294 () = [ Entity { db_id = Some (Entity_id 1) ; attrs = - [ "a1", One_value (Int 1) - ; "a2", One_value (Int 2) - ; "a3", One_value (Int 3) + [ "a1", One_value (Int64 1L) + ; "a2", One_value (Int64 2L) + ; "a3", One_value (Int64 3L) ] } ; Entity { db_id = Some (Entity_id 2) ; attrs = - [ "a1", One_value (Int 1) - ; "a2", One_value (Int 2) - ; "a3", One_value (Int 3) + [ "a1", One_value (Int64 1L) + ; "a2", One_value (Int64 2L) + ; "a3", One_value (Int64 3L) ] } ] @@ -14378,12 +14378,12 @@ let test_transact__test_transient_issue_294 () = let report = transact db [ RetractEntity (Entity_id 1); RetractEntity (Entity_id 2) ] in assert_equal_datoms "RetractEntity tx_data reports retractions in EAVT order" - [ datom ~tx:(tx0 + 2) ~added:false ~e:1 ~a:"a1" ~v:(Int 1) () - ; datom ~tx:(tx0 + 2) ~added:false ~e:1 ~a:"a2" ~v:(Int 2) () - ; datom ~tx:(tx0 + 2) ~added:false ~e:1 ~a:"a3" ~v:(Int 3) () - ; datom ~tx:(tx0 + 2) ~added:false ~e:2 ~a:"a1" ~v:(Int 1) () - ; datom ~tx:(tx0 + 2) ~added:false ~e:2 ~a:"a2" ~v:(Int 2) () - ; datom ~tx:(tx0 + 2) ~added:false ~e:2 ~a:"a3" ~v:(Int 3) () + [ datom ~tx:(tx0 + 2) ~added:false ~e:1 ~a:"a1" ~v:(Int64 1L) () + ; datom ~tx:(tx0 + 2) ~added:false ~e:1 ~a:"a2" ~v:(Int64 2L) () + ; datom ~tx:(tx0 + 2) ~added:false ~e:1 ~a:"a3" ~v:(Int64 3L) () + ; datom ~tx:(tx0 + 2) ~added:false ~e:2 ~a:"a1" ~v:(Int64 1L) () + ; datom ~tx:(tx0 + 2) ~added:false ~e:2 ~a:"a2" ~v:(Int64 2L) () + ; datom ~tx:(tx0 + 2) ~added:false ~e:2 ~a:"a3" ~v:(Int64 3L) () ] report.tx_data @@ -14452,7 +14452,7 @@ let test_pull_selects_requested_attributes () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 31) + ; "age", One_value (Int64 31L) ; "aka", Many_values [ String "IV"; String "Terrible" ] ] } @@ -14509,7 +14509,7 @@ let test_parse_pull_pattern_selects_attributes_and_refs () = | Some entity -> assert_equal_pulled_attrs "parse_pull_pattern parses wildcard selector" - [ kw "db/id", Pulled_scalar (Int 2); kw "name", Pulled_scalar (String "Petr") ] + [ kw "db/id", Pulled_scalar (Int64 2L); kw "name", Pulled_scalar (String "Petr") ] entity); let string_wildcard_pattern = parse_pull_pattern db (QueryFormVector [ QueryFormString "*" ]) in (match pull db string_wildcard_pattern (Entity_id 2) with @@ -14517,7 +14517,7 @@ let test_parse_pull_pattern_selects_attributes_and_refs () = | Some entity -> assert_equal_pulled_attrs "parse_pull_pattern parses string wildcard selector" - [ kw "db/id", Pulled_scalar (Int 2); kw "name", Pulled_scalar (String "Petr") ] + [ kw "db/id", Pulled_scalar (Int64 2L); kw "name", Pulled_scalar (String "Petr") ] entity); let keyword_wildcard_pattern = parse_pull_pattern db (QueryFormVector [ QueryFormKeyword "*" ]) in (match pull db keyword_wildcard_pattern (Entity_id 2) with @@ -14525,7 +14525,7 @@ let test_parse_pull_pattern_selects_attributes_and_refs () = | Some entity -> assert_equal_pulled_attrs "parse_pull_pattern parses keyword wildcard selector" - [ kw "db/id", Pulled_scalar (Int 2); kw "name", Pulled_scalar (String "Petr") ] + [ kw "db/id", Pulled_scalar (Int64 2L); kw "name", Pulled_scalar (String "Petr") ] entity) let test_parse_pull_pattern_accepts_top_level_lists () = @@ -14549,13 +14549,13 @@ let test_parse_pull_pattern_accepts_string_db_id () = assert_pull "parse_pull_pattern treats string :db/id as db/id" (parse_pull_pattern db (QueryFormVector [ QueryFormString ":db/id" ])) - [ kw "db/id", Pulled_scalar (Int 1) ]; + [ kw "db/id", Pulled_scalar (Int64 1L) ]; (match pull_string db "[\":db/id\"]" (Entity_id 1) with | None -> failwith "expected pull_string string :db/id to pull the entity" | Some entity -> assert_equal_pulled_attrs "pull_string treats string :db/id as db/id" - [ kw "db/id", Pulled_scalar (Int 1) ] + [ kw "db/id", Pulled_scalar (Int64 1L) ] entity); assert_pull "parse_pull_pattern aliases string :db/id" @@ -14563,14 +14563,14 @@ let test_parse_pull_pattern_accepts_string_db_id () = db (QueryFormVector [ QueryFormVector [ QueryFormString ":db/id"; QueryFormKeyword "as"; QueryFormKeyword "id" ] ])) - [ kw "id", Pulled_scalar (Int 1) ]; + [ kw "id", Pulled_scalar (Int64 1L) ]; assert_pull "parse_pull_pattern applies vector xform to string :db/id" (parse_pull_pattern db (QueryFormVector [ QueryFormVector [ QueryFormString ":db/id"; QueryFormKeyword "xform"; QueryFormSymbol "vector" ] ])) - [ kw "db/id", Pulled_many [ Pulled_scalar (Int 1) ] ] + [ kw "db/id", Pulled_many [ Pulled_scalar (Int64 1L) ] ] let test_parse_pull_pattern_aliases_attributes () = let db = empty_db () |> db_with [ Add (Entity_id 1, "name", String "Ivan") ] in @@ -14601,7 +14601,7 @@ let test_parse_pull_pattern_accepts_upstream_alias_value_forms () = in assert_alias "[(:name :as :display/name)]" (kw "display/name"); assert_alias "[(:name :as \"display-name\")]" (str_key "display-name"); - assert_alias "[(:name :as 123)]" (Int 123); + assert_alias "[(:name :as 123)]" (Int64 123L); assert_alias "[(:name :as nil)]" Nil let test_parse_pull_pattern_defaults_attributes () = @@ -14634,7 +14634,7 @@ let test_parse_pull_pattern_limits_attributes () = parse_pull_pattern db (QueryFormVector - [ QueryFormVector [ QueryFormKeyword "aka"; QueryFormKeyword "limit"; QueryFormInt 2 ] ]) + [ QueryFormVector [ QueryFormKeyword "aka"; QueryFormKeyword "limit"; QueryFormInt 2L ] ]) in match pull db pattern (Entity_id 1) with | None -> failwith "expected parsed pull limit pattern to find entity" @@ -14663,7 +14663,7 @@ let test_parse_pull_pattern_legacy_limit_and_default () = parse_pull_pattern db (QueryFormVector - [ QueryFormVector [ QueryFormString "limit"; QueryFormKeyword "aka"; QueryFormInt 1 ] + [ QueryFormVector [ QueryFormString "limit"; QueryFormKeyword "aka"; QueryFormInt 1L ] ; QueryFormVector [ QueryFormString "default"; QueryFormKeyword "missing"; QueryFormString "fallback" ] ]) in @@ -14678,10 +14678,10 @@ let test_parse_pull_pattern_legacy_limit_and_default () = parse_pull_pattern db (QueryFormVector - [ QueryFormList [ QueryFormSymbol "limit"; QueryFormKeyword "aka"; QueryFormInt 2 ] + [ QueryFormList [ QueryFormSymbol "limit"; QueryFormKeyword "aka"; QueryFormInt 2L ] ; QueryFormList [ QueryFormSymbol "default"; QueryFormKeyword "missing"; QueryFormString "fallback" ] ; QueryFormMap - [ ( QueryFormList [ QueryFormSymbol "limit"; QueryFormKeyword "friend"; QueryFormInt 1 ] + [ ( QueryFormList [ QueryFormSymbol "limit"; QueryFormKeyword "friend"; QueryFormInt 1L ] , QueryFormVector [ QueryFormKeyword "name" ] ) ] ]) @@ -14801,7 +14801,7 @@ let test_parse_pull_pattern_validates_limits () = ignore (parse_pull_pattern db - (QueryFormVector [ QueryFormVector [ QueryFormKeyword "aka"; QueryFormKeyword "limit"; QueryFormInt 0 ] ]))); + (QueryFormVector [ QueryFormVector [ QueryFormKeyword "aka"; QueryFormKeyword "limit"; QueryFormInt 0L ] ]))); assert_raises_invalid_arg "parse_pull_pattern rejects negative limits" (fun () -> @@ -14809,14 +14809,14 @@ let test_parse_pull_pattern_validates_limits () = (parse_pull_pattern db (QueryFormVector - [ QueryFormVector [ QueryFormKeyword "aka"; QueryFormKeyword "limit"; QueryFormInt (-1) ] ]))); + [ QueryFormVector [ QueryFormKeyword "aka"; QueryFormKeyword "limit"; QueryFormInt (-1L) ] ]))); assert_raises_invalid_arg "parse_pull_pattern rejects limits on cardinality-one attrs" (fun () -> ignore (parse_pull_pattern db - (QueryFormVector [ QueryFormVector [ QueryFormKeyword "name"; QueryFormKeyword "limit"; QueryFormInt 1 ] ]))); + (QueryFormVector [ QueryFormVector [ QueryFormKeyword "name"; QueryFormKeyword "limit"; QueryFormInt 1L ] ]))); assert_raises_invalid_arg "parse_pull_pattern rejects nil limits on cardinality-one refs" (fun () -> @@ -14830,7 +14830,7 @@ let test_parse_pull_pattern_validates_limits () = ignore (parse_pull_pattern db - (QueryFormVector [ QueryFormVector [ QueryFormString "limit"; QueryFormKeyword "name"; QueryFormInt 1 ] ]))) + (QueryFormVector [ QueryFormVector [ QueryFormString "limit"; QueryFormKeyword "name"; QueryFormInt 1L ] ]))) let test_parse_pull_pattern_unlimited_limits () = let many_akas = @@ -14894,7 +14894,7 @@ let test_parse_pull_pattern_xforms_attributes () = { db_id = Some (Entity_id 1) ; attrs = [ "kind", One_value (Keyword "user/name") - ; "age", One_value (Int 42) + ; "age", One_value (Int64 42L) ; "aka", Many_values [ String "Ivan"; String "Vanya" ] ] } @@ -15127,7 +15127,7 @@ let test_parse_pull_pattern_recursive_refs () = parse_pull_pattern db (QueryFormVector - [ QueryFormKeyword "name"; QueryFormMap [ QueryFormKeyword "part", QueryFormInt 2 ] ]) + [ QueryFormKeyword "name"; QueryFormMap [ QueryFormKeyword "part", QueryFormInt 2L ] ]) in match pull db pattern (Entity_id 1) with | None -> failwith "expected parsed recursive pull pattern to find entity" @@ -15175,7 +15175,7 @@ let test_parse_pull_pattern_recursive_refs_preserve_context () = parse_pull_pattern db (QueryFormVector - [ QueryFormKeyword "label"; QueryFormMap [ QueryFormKeyword "part", QueryFormInt 2 ] ]) + [ QueryFormKeyword "label"; QueryFormMap [ QueryFormKeyword "part", QueryFormInt 2L ] ]) in match pull db pattern (Entity_id 1) with | None -> failwith "expected parsed recursive pull pattern to find entity" @@ -15234,7 +15234,7 @@ let test_parse_pull_pattern_recursive_string_ellipsis () = { pulled_id = 1 ; pulled_attrs = [ kw "name", Pulled_scalar (String "A") - ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] } ] @@ -15715,13 +15715,13 @@ let test_pull_component_attr_expands_recursively () = , Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) + [ kw "db/id", Pulled_scalar (Int64 2L) ; kw "email", Pulled_scalar (String "ivan@example.com") ; ( kw "profile" , Pulled_entity { pulled_id = 3 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 3) + [ kw "db/id", Pulled_scalar (Int64 3L) ; kw "email", Pulled_scalar (String "nested@example.com") ] } ) @@ -15753,9 +15753,9 @@ let test_pull_component_attr_returns_id_stub_for_cycles () = , Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) + [ kw "db/id", Pulled_scalar (Int64 2L) ; kw "email", Pulled_scalar (String "ivan@example.com") - ; kw "profile", Pulled_entity { pulled_id = 1; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 1) ] } + ; kw "profile", Pulled_entity { pulled_id = 1; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 1L) ] } ] } ) ] @@ -15837,7 +15837,7 @@ let test_pull_id_and_wildcard () = | Some entity -> assert_equal_pulled_attrs "Pull_id returns db/id" - [ kw "db/id", Pulled_scalar (Int 1) ] + [ kw "db/id", Pulled_scalar (Int64 1L) ] entity); (match pull db [ Pull_wildcard ] (Entity_id 1) with | None -> failwith "expected wildcard pull" @@ -15846,10 +15846,10 @@ let test_pull_id_and_wildcard () = "Pull_wildcard returns all current attrs and shallow refs" [ kw "aka", Pulled_many [ Pulled_scalar (String "Devil"); Pulled_scalar (String "Tupen") ] ; kw "child", Pulled_many - [ Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } - ; Pulled_entity { pulled_id = 3; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 3) ] } + [ Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } + ; Pulled_entity { pulled_id = 3; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 3L) ] } ] - ; kw "db/id", Pulled_scalar (Int 1) + ; kw "db/id", Pulled_scalar (Int64 1L) ; kw "name", Pulled_scalar (String "Petr") ] entity); @@ -15860,10 +15860,10 @@ let test_pull_id_and_wildcard () = "Pull_wildcard does not re-emit attrs selected with aliases" [ kw "alias", Pulled_many [ Pulled_scalar (String "Devil"); Pulled_scalar (String "Tupen") ] ; kw "child", Pulled_many - [ Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } - ; Pulled_entity { pulled_id = 3; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 3) ] } + [ Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } + ; Pulled_entity { pulled_id = 3; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 3L) ] } ] - ; kw "db/id", Pulled_scalar (Int 1) + ; kw "db/id", Pulled_scalar (Int64 1L) ; kw "first-name", Pulled_scalar (String "Petr") ] entity); @@ -15873,7 +15873,7 @@ let test_pull_id_and_wildcard () = assert_equal_pulled_attrs "Pull_attr returns db/id stubs for shallow reverse refs" [ kw "_child", Pulled_many - [ Pulled_entity { pulled_id = 1; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 1) ] } ] + [ Pulled_entity { pulled_id = 1; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 1L) ] } ] ] entity @@ -15998,7 +15998,7 @@ let test_pull_recursive_ref_avoids_cycles () = { pulled_id = 1 ; pulled_attrs = [ kw "name", Pulled_scalar (String "A") - ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] } ] @@ -16069,17 +16069,17 @@ let test_pull_recursive_ref_depth_preserves_sibling_context () = | Some entity -> assert_equal_pulled_attrs "exhausting one recursive attr depth should preserve sibling recursive attrs" - [ kw "db/id", Pulled_scalar (Int 1) + [ kw "db/id", Pulled_scalar (Int64 1L) ; kw "friend", Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) + [ kw "db/id", Pulled_scalar (Int64 2L) ; kw "enemy", Pulled_entity { pulled_id = 3 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 3) + [ kw "db/id", Pulled_scalar (Int64 3L) ; kw "friend", Pulled_entity - { pulled_id = 4; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 4) ] } + { pulled_id = 4; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 4L) ] } ] } ] @@ -16111,8 +16111,8 @@ let test_pull_dual_recursion_respects_independent_depths () = | Some entity -> assert_equal_pulled_attrs "unbounded recursion follows only the selected recursive attr" - [ kw "db/id", Pulled_scalar (Int 1) - ; kw "friend", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + [ kw "db/id", Pulled_scalar (Int64 1L) + ; kw "friend", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] entity); (match @@ -16128,12 +16128,12 @@ let test_pull_dual_recursion_respects_independent_depths () = | Some entity -> assert_equal_pulled_attrs "dual recursion follows each attr at depth one" - [ kw "db/id", Pulled_scalar (Int 1) + [ kw "db/id", Pulled_scalar (Int64 1L) ; kw "friend", Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) - ; kw "enemy", Pulled_entity { pulled_id = 3; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 3) ] } + [ kw "db/id", Pulled_scalar (Int64 2L) + ; kw "enemy", Pulled_entity { pulled_id = 3; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 3L) ] } ] } ] @@ -16151,21 +16151,21 @@ let test_pull_dual_recursion_respects_independent_depths () = | Some entity -> assert_equal_pulled_attrs "dual recursion tracks attr depths independently" - [ kw "db/id", Pulled_scalar (Int 1) + [ kw "db/id", Pulled_scalar (Int64 1L) ; kw "friend", Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) + [ kw "db/id", Pulled_scalar (Int64 2L) ; kw "enemy", Pulled_entity { pulled_id = 3 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 3) + [ kw "db/id", Pulled_scalar (Int64 3L) ; kw "friend", Pulled_entity { pulled_id = 4 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 4) + [ kw "db/id", Pulled_scalar (Int64 4L) ; kw "enemy", Pulled_entity - { pulled_id = 5; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 5) ] } + { pulled_id = 5; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 5L) ] } ] } ] @@ -16199,21 +16199,21 @@ let test_pull_dual_recursion_tracks_cycles_per_branch () = | Some entity -> assert_equal_pulled_attrs "dual recursion tracks seen ids independently for sibling branches" - [ kw "db/id", Pulled_scalar (Int 1) + [ kw "db/id", Pulled_scalar (Int64 1L) ; kw "part", Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) + [ kw "db/id", Pulled_scalar (Int64 2L) ; kw "part", Pulled_entity { pulled_id = 3 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 3) + [ kw "db/id", Pulled_scalar (Int64 3L) ; kw "part", Pulled_entity { pulled_id = 1 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 1) - ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } - ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + [ kw "db/id", Pulled_scalar (Int64 1L) + ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } + ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] } ] @@ -16221,9 +16221,9 @@ let test_pull_dual_recursion_tracks_cycles_per_branch () = ; kw "spec", Pulled_entity { pulled_id = 1 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 1) - ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } - ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + [ kw "db/id", Pulled_scalar (Int64 1L) + ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } + ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] } ] @@ -16231,17 +16231,17 @@ let test_pull_dual_recursion_tracks_cycles_per_branch () = ; kw "spec", Pulled_entity { pulled_id = 2 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 2) + [ kw "db/id", Pulled_scalar (Int64 2L) ; kw "part", Pulled_entity { pulled_id = 3 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 3) + [ kw "db/id", Pulled_scalar (Int64 3L) ; kw "part", Pulled_entity { pulled_id = 1 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 1) - ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } - ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + [ kw "db/id", Pulled_scalar (Int64 1L) + ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } + ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] } ] @@ -16249,9 +16249,9 @@ let test_pull_dual_recursion_tracks_cycles_per_branch () = ; kw "spec", Pulled_entity { pulled_id = 1 ; pulled_attrs = - [ kw "db/id", Pulled_scalar (Int 1) - ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } - ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 2) ] } + [ kw "db/id", Pulled_scalar (Int64 1L) + ; kw "part", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } + ; kw "spec", Pulled_entity { pulled_id = 2; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 2L) ] } ] } ] @@ -16342,22 +16342,22 @@ let test_pull_recursive_reverse_ref () = [ kw "_friend", Pulled_many [ Pulled_entity { pulled_id = 4 - ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 4) ] + ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 4L) ] } ] - ; kw "db/id", Pulled_scalar (Int 5) + ; kw "db/id", Pulled_scalar (Int64 5L) ] } ] - ; kw "db/id", Pulled_scalar (Int 6) + ; kw "db/id", Pulled_scalar (Int64 6L) ] } ] - ; kw "db/id", Pulled_scalar (Int 7) + ; kw "db/id", Pulled_scalar (Int64 7L) ] } ] - ; kw "db/id", Pulled_scalar (Int 8) + ; kw "db/id", Pulled_scalar (Int64 8L) ] entity); match pull db [ Pull_id; Pull_recursive_ref ("_friend", [ Pull_id ], Some 2) ] (Entity_id 8) with @@ -16372,14 +16372,14 @@ let test_pull_recursive_reverse_ref () = [ kw "_friend", Pulled_many [ Pulled_entity { pulled_id = 6 - ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int 6) ] + ; pulled_attrs = [ Keyword "db/id", Pulled_scalar (Int64 6L) ] } ] - ; kw "db/id", Pulled_scalar (Int 7) + ; kw "db/id", Pulled_scalar (Int64 7L) ] } ] - ; kw "db/id", Pulled_scalar (Int 8) + ; kw "db/id", Pulled_scalar (Int64 8L) ] entity @@ -16567,7 +16567,7 @@ let test_filter_and_entity_upstream_edge_parity_batch () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Petr") - ; "age", One_value (Int 44) + ; "age", One_value (Int64 44L) ; "aka", Many_values [ String "I"; String "Great" ] ; "password", One_value (String "") ; "huh?", One_value (Bool false) @@ -16577,7 +16577,7 @@ let test_filter_and_entity_upstream_edge_parity_batch () = { db_id = Some (Entity_id 2) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 25) + ; "age", One_value (Int64 25L) ; "aka", Many_values [ String "Terrible"; String "IV" ] ; "password", One_value (String "") ] @@ -16586,7 +16586,7 @@ let test_filter_and_entity_upstream_edge_parity_batch () = { db_id = Some (Entity_id 3) ; attrs = [ "name", One_value (String "Nikolai") - ; "age", One_value (Int 7) + ; "age", One_value (Int64 7L) ; "aka", Many_values [ String "II" ] ; "password", One_value (String "") ] @@ -16604,7 +16604,7 @@ let test_filter_and_entity_upstream_edge_parity_batch () = match entity db (Entity_id entity_id) with | Some entity -> (match entity_attr entity "age" with - | Some (One_value (Int age)) -> Some age + | Some (One_value (Int64 age)) -> Some age | _ -> None) | None -> None in @@ -16620,7 +16620,7 @@ let test_filter_and_entity_upstream_edge_parity_batch () = let has_age unfiltered_db datom = Option.is_some (age_of unfiltered_db datom.e) in let adult unfiltered_db datom = match age_of unfiltered_db datom.e with - | Some age -> age >= 18 + | Some age -> age >= 18L | None -> false in let long_akas unfiltered_db datom = @@ -16771,7 +16771,7 @@ let test_schema_accepts_db_type_alias () = ; "db/cardinality", One_value (Keyword "db.cardinality/one") ] } - ; Entity { db_id = Some (Entity_id 1); attrs = [ "friend", One_value (Int 2) ] } + ; Entity { db_id = Some (Entity_id 1); attrs = [ "friend", One_value (Int64 2L) ] } ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Petr") ] } ] in @@ -17251,7 +17251,7 @@ let test_scalar_value_type_schema_validates_values () = |> db_with [ Add (Entity_id 1, "name", String "Ivan") ; Add (Entity_id 1, "tag", Keyword "user/admin") - ; Add (Entity_id 1, "score", Int 10) + ; Add (Entity_id 1, "score", Int64 10L) ; Add (Entity_id 1, "score", Float 10.5) ] in @@ -17324,7 +17324,7 @@ let test_uuid_and_instant_value_type_schema_validates_values () = (fun () -> ignore (db_with [ Add (Entity_id 1, "uuid", String "65ec87fb") ] db)); assert_raises_invalid_arg "InstantType rejects non-instant values" - (fun () -> ignore (db_with [ Add (Entity_id 1, "created-at", Int 1_710_000_123_456) ] db)) + (fun () -> ignore (db_with [ Add (Entity_id 1, "created-at", Int64 1_710_000_123_456L) ] db)) let test_schema_transactions_install_uuid_and_instant_value_types () = let db = diff --git a/test/test_db.ml b/test/test_db.ml index 6cb612c..9cbd961 100644 --- a/test/test_db.ml +++ b/test/test_db.ml @@ -19,7 +19,7 @@ let hash_hash_beef (_ : hash_beef) = 0xBEEF let rec debug_value = function | Nil -> "nil" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> Printf.sprintf "%S" value | Symbol value -> value @@ -92,18 +92,16 @@ let test_db__test_db_hash_cache () = assert_equal_int "different db identity gets a separate hash cache entry" (before + 2) (db_hash_cache_size ()) let test_db__test_uuid () = - let first = squuid ~msec:1_710_000_123_456 () in - let second = squuid ~msec:1_710_000_123_456 () in + let first = squuid ~msec:1_710_000_123_456L () in + let second = squuid ~msec:1_710_000_123_456L () in if first = second then failwith "squuid should include random bits"; let first_uuid = match first with | Uuid uuid -> uuid | _ -> failwith "squuid should return a Uuid value" in - assert_equal_int - "squuid_time_millis returns the embedded second" - 1_710_000_123_000 - (squuid_time_millis first); + if not (Int64.equal (squuid_time_millis first) 1_710_000_123_000L) then + failwith "squuid_time_millis should return the embedded second"; assert_equal_string "squuid uses the timestamp as its first UUID segment" "65ec87fb" @@ -129,27 +127,27 @@ let test_db__test_diff () = let left = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "a", One_value (Int 1); "b", One_value (Int 2); "c", One_value (Int 4) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "a", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "a", One_value (Int64 1L); "b", One_value (Int64 2L); "c", One_value (Int64 4L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "a", One_value (Int64 1L) ] } ] in let right = empty_db () - |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "b", One_value (Int 3); "d", One_value (Int 5) ] } ] - |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "a", One_value (Int 1) ] } ] + |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "b", One_value (Int64 3L); "d", One_value (Int64 5L) ] } ] + |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "a", One_value (Int64 1L) ] } ] in let only_left, only_right, both = diff left right in assert_equal_triples "db diff returns datoms only on the left" - [ 1, "b", Int 2; 1, "c", Int 4; 2, "a", Int 1 ] + [ 1, "b", Int64 2L; 1, "c", Int64 4L; 2, "a", Int64 1L ] only_left; assert_equal_triples "db diff returns datoms only on the right" - [ 1, "b", Int 3; 1, "d", Int 5 ] + [ 1, "b", Int64 3L; 1, "d", Int64 5L ] only_right; assert_equal_triples "db diff returns datoms present in both dbs" - [ 1, "a", Int 1 ] + [ 1, "a", Int64 1L ] both let test_db__test_index_api () = @@ -207,22 +205,22 @@ let test_db__test_index_lookup_matches_upstream_numeric_comparator_bounds () = let db = empty_db ~schema:[ "x", { indexed with cardinality = Many } ] () |> db_with - [ Add (Entity_id 1, "x", Int 1) + [ Add (Entity_id 1, "x", Int64 1L) ; Add (Entity_id 2, "x", Float 1.0) - ; Add (Entity_id 3, "x", Int 2) + ; Add (Entity_id 3, "x", Int64 2L) ] in assert_equal_triples "AVET exact int lookup includes comparator-equal float values like upstream DataScript" - [ 1, "x", Int 1; 2, "x", Float 1.0 ] - (Db.datoms db Avet ~a:"x" ~v:(Int 1) () |> List.of_seq); + [ 1, "x", Int64 1L; 2, "x", Float 1.0 ] + (Db.datoms db Avet ~a:"x" ~v:(Int64 1L) () |> List.of_seq); assert_equal_triples "AVET exact float lookup includes comparator-equal int values like upstream DataScript" - [ 1, "x", Int 1; 2, "x", Float 1.0 ] + [ 1, "x", Int64 1L; 2, "x", Float 1.0 ] (Db.datoms db Avet ~a:"x" ~v:(Float 1.0) () |> List.of_seq); assert_equal_triples "AVET range preserves comparator-bound numeric behavior" - [ 1, "x", Int 1; 2, "x", Float 1.0 ] + [ 1, "x", Int64 1L; 2, "x", Float 1.0 ] (Db.index_range db "x" ~start:(Float 1.0) ~stop:(Float 1.0) () |> List.of_seq) let () = diff --git a/test/test_entity.ml b/test/test_entity.ml index 5326282..28ccf17 100644 --- a/test/test_entity.ml +++ b/test/test_entity.ml @@ -78,7 +78,7 @@ let test_entity__test_entity () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 19) + ; "age", One_value (Int64 19L) ; "aka", Many_values [ String "X"; String "Y" ] ] } @@ -101,7 +101,7 @@ let test_entity__test_entity () = assert_equal_int "entity id" 1 entity.id; assert_equal_tx_value "entity exposes db/id as a virtual attribute" - (Some (One_value (Int 1))) + (Some (One_value (Int64 1L))) (entity_attr entity "db/id"); assert_equal_tx_value "entity reads current cardinality-one value" @@ -109,7 +109,7 @@ let test_entity__test_entity () = (entity_attr entity "name"); assert_equal_tx_value "entity reads ordinary scalar attrs" - (Some (One_value (Int 19))) + (Some (One_value (Int64 19L))) (entity_attr entity "age"); assert_equal_tx_value "entity reads current cardinality-many values" @@ -243,7 +243,7 @@ let test_entity__test_entity_misses () = failwith "incoming refs alone should not make an entity exist"; assert_raises_invalid_arg "entity lookup refs require unique attrs like upstream" - (fun () -> ignore (entity db (Lookup_ref ("not-an-attr", Int 777)))) + (fun () -> ignore (entity db (Lookup_ref ("not-an-attr", Int64 777L)))) let test_entity__test_entity_equality () = let db1 = diff --git a/test/test_int64.ml b/test/test_int64.ml new file mode 100644 index 0000000..477e2f1 --- /dev/null +++ b/test/test_int64.ml @@ -0,0 +1,193 @@ +open Datascript + +let failf fmt = Printf.ksprintf failwith fmt + +let expect label expected actual = + if Int64.compare expected actual <> 0 then + failf "%s: expected %s, got %s" label (Int64.to_string expected) (Int64.to_string actual) + +let expect_true label cond = if not cond then failf "%s" label + +let expect_value label expected actual = if not (Util.value_equal expected actual) then failf "%s" label + +let number_attr = { cardinality = One; unique = None; indexed = false; is_component = false; no_history = false; doc = None; value_type = Some NumberType; tuple_attrs = None; tuple_types = None } + +let instant_attr = { cardinality = One; unique = None; indexed = false; is_component = false; no_history = false; doc = None; value_type = Some InstantType; tuple_attrs = None; tuple_types = None } + +let epoch_ms = 1_700_000_000_000L + +let test_int64_values_roundtrip () = + let db = + empty_db () + |> db_with + [ Add (Entity_id 1, "epoch-ms", Int64 epoch_ms) + ; Add (Entity_id 1, "int64-min", Int64 Int64.min_int) + ; Add (Entity_id 1, "int64-max", Int64 Int64.max_int) + ; Add (Entity_id 1, "negative", Int64 (-4_000_000_000_000L)) + ] + in + let values = + datoms db Eavt () + |> List.of_seq + |> List.map (fun d -> d.a, d.v) + in + (match List.assoc "epoch-ms" values with + | Int64 value -> expect "epoch-ms stays Int64 without 32-bit overflow" epoch_ms value + | Instant _ -> failwith "epoch-ms must not become Instant" + | _ -> failwith "epoch-ms decoded to unexpected constructor"); + (match List.assoc "int64-min" values with + | Int64 value -> expect "int64 min boundary" Int64.min_int value + | _ -> failwith "int64 min decoded to unexpected constructor"); + (match List.assoc "int64-max" values with + | Int64 value -> expect "int64 max boundary" Int64.max_int value + | _ -> failwith "int64 max decoded to unexpected constructor"); + (match List.assoc "negative" values with + | Int64 value -> expect "negative int64" (-4_000_000_000_000L) value + | _ -> failwith "negative int64 decoded to unexpected constructor") + +let test_int64_equality_and_ordering () = + expect_true "Int64 1 is not equal to Float 1.0" (not (Util.value_equal (Int64 1L) (Float 1.0))); + expect_true "Int64 1 orders with Float 1.0" (Util.compare_value (Int64 1L) (Float 1.0) = 0); + expect_true "Int64 5 is comparable to Instant 5" (Util.compare_value (Int64 5L) (Instant 5L) = 0); + expect_true "Int64 5 is never equal to Instant 5" (not (Util.value_equal (Int64 5L) (Instant 5L))); + expect_true "Instant 4 sorts below Int64 5" (Util.compare_value (Instant 4L) (Int64 5L) < 0); + expect_true "Int64 5 sorts below Instant 6" (Util.compare_value (Int64 5L) (Instant 6L) < 0); + expect_true "Int64 ordering uses full 64-bit range" (Util.compare_value (Int64 Int64.max_int) (Int64 1L) > 0); + expect_true "Int64 min sorts below max" (Util.compare_value (Int64 Int64.min_int) (Int64 Int64.max_int) < 0) + +let test_int64_predicates () = + expect_true "number? accepts Int64" (Built_ins.matches_value_predicate NumberValue (Int64 1L)); + expect_true "integer? accepts Int64" (Built_ins.matches_value_predicate IntegerValue (Int64 1L)); + expect_true "number? rejects Instant" (not (Built_ins.matches_value_predicate NumberValue (Instant 1L))); + expect_true "integer? rejects Instant" (not (Built_ins.matches_value_predicate IntegerValue (Instant 1L))); + expect_true "integer? rejects Float" (not (Built_ins.matches_value_predicate IntegerValue (Float 1.0))); + expect_true "zero? on Int64" (Built_ins.matches_numeric_predicate ZeroNumber (Int64 0L)); + expect_true "even? on Int64" (Built_ins.matches_numeric_predicate EvenInteger (Int64 4L)); + expect_true "odd? on Int64" (Built_ins.matches_numeric_predicate OddInteger (Int64 3L)) + +let test_int64_edn () = + (match read_edn "1700000000000" with + | QueryFormInt value -> expect "EDN int literal parses to int64" 1_700_000_000_000L value + | _ -> failwith "EDN int literal did not parse as int64"); + (match read_edn "9223372036854775807" with + | QueryFormInt value -> expect "EDN int64 max literal" Int64.max_int value + | _ -> failwith "EDN int64 max literal did not parse as int64"); + let db = + empty_db ~schema:[ "created-at", instant_attr ] () + |> db_with_string "[{:db/id 1 :created-at #inst \"2024-03-09T16:02:03.456Z\"}]" + in + (match List.of_seq (datoms db Eavt ~a:"created-at" ()) with + | [ datom ] -> expect_value "#inst transacts as Instant" (Instant 1_710_000_123_456L) datom.v + | _ -> failwith "#inst datom missing"); + expect_true "Instant prints as #inst readably" + (Built_ins.print_query_value ~readably:true (Instant 1_710_000_123_456L) + = "#inst \"2024-03-09T16:02:03.456Z\"") + +let test_int64_query () = + let db = + empty_db () + |> db_with + [ Add (Entity_id 1, "ms", Int64 1_000_000_000_000L) + ; Add (Entity_id 2, "ms", Int64 1_700_000_000_000L) + ; Add (Entity_id 3, "ms", Int64 9_223_372_036_854_775_000L) + ] + in + (match q_string db "[:find ?v :where [?e :ms ?v] [(> ?v 1600000000000)]]" with + | rows -> + let values = + List.filter_map + (function [ Result_value (Int64 v) ] -> Some v | _ -> None) + rows + |> List.sort Int64.compare + in + if values <> [ 1_700_000_000_000L; 9_223_372_036_854_775_000L ] then + failwith "range filter dropped int64 rows"); + (match q_string db "[:find ?v . :where [?e :ms ?v] [(> ?v 1699999999999)] [(< ?v 9223372036854775000)]]" with + | [ [ Result_value (Int64 value) ] ] -> expect "compound int64 filter" 1_700_000_000_000L value + | _ -> failwith "compound int64 filter returned unexpected result"); + (match q_string db "[:find (max ?v) . :where [_ :ms ?v]]" with + | [ [ Result_value (Int64 value) ] ] -> expect "max aggregate on int64" 9_223_372_036_854_775_000L value + | _ -> failwith "max aggregate on int64 returned unexpected result"); + (match q_string db "[:find ?v :where [?e :ms ?v] [(number? ?v)]]" with + | rows when List.length rows = 3 -> () + | rows -> failf "number? query on int64 returned unexpected result (%d rows)" (List.length rows)) + +let test_int64_transit_codec () = + let module T = Transit_native.Transit.Json in + (match Datascript_sqlite_codec.value_to_transit (Int64 epoch_ms) with + | T.Int64 value -> expect "Int64 encodes to Transit.Int64" epoch_ms value + | _ -> failwith "Int64 must encode to Transit.Int64 unconditionally"); + (match Datascript_sqlite_codec.value_to_transit (Instant epoch_ms) with + | T.Date value -> expect "Instant encodes to Transit.Date" epoch_ms value + | _ -> failwith "Instant must encode to Transit.Date"); + expect_value "Transit.Int64 decodes to Int64" (Int64 epoch_ms) (Datascript_sqlite_codec.value_of_transit (T.Int64 epoch_ms)); + expect_value "legacy Transit.Int decodes to Int64" (Int64 42L) (Datascript_sqlite_codec.value_of_transit (T.Int 42)); + expect_value + "legacy Transit.Big_int decodes to Int64" + (Int64 epoch_ms) + (Datascript_sqlite_codec.value_of_transit (T.Big_int "1700000000000")); + expect_value "Transit.Date decodes to Instant" (Instant epoch_ms) (Datascript_sqlite_codec.value_of_transit (T.Date epoch_ms)); + expect_value + "legacy ~m int64 tag decodes to Instant" + (Instant epoch_ms) + (Datascript_sqlite_codec.value_of_transit (T.Tagged ("m", T.Int64 epoch_ms))); + expect_value + "legacy ~m int tag decodes to Instant" + (Instant 42L) + (Datascript_sqlite_codec.value_of_transit (T.Tagged ("m", T.Int 42))) + +let test_int64_storage_migration () = + (* legacy builds stored plain integers as Instant; on restore only + db.type/instant attrs may keep Instant *) + let storage = memory_storage () in + let schema = [ "count", number_attr; "created-at", instant_attr ] in + let db = + init_db ~schema ~storage + [ Db.datom ~e:1 ~a:"count" ~v:(Instant epoch_ms) () + ; Db.datom ~e:1 ~a:"created-at" ~v:(Instant epoch_ms) () + ; Db.datom ~e:1 ~a:"untyped-time" ~v:(Instant epoch_ms) () + ; Db.datom ~e:2 ~a:"count" ~v:(Int64 9_223_372_036_854_775_000L) () + ] + in + store ~storage db; + (match restore storage with + | None -> failwith "restore failed" + | Some restored -> + let value_for e a = + match List.of_seq (datoms restored Eavt ~e ~a ()) with + | [ d ] -> d.v + | _ -> failwith ("missing datom for " ^ a) + in + expect_value "legacy Instant under numeric attr migrates to Int64" (Int64 epoch_ms) (value_for 1 "count"); + expect_value "Instant under instant attr stays Instant" (Instant epoch_ms) (value_for 1 "created-at"); + expect_value "Instant under untyped attr migrates to Int64" (Int64 epoch_ms) (value_for 1 "untyped-time"); + expect_value "big Int64 survives kvs restore" (Int64 9_223_372_036_854_775_000L) (value_for 2 "count")) + +let test_int64_lookup_ref_and_entity () = + let db = + empty_db ~schema:[ "email", { cardinality = One; unique = Some Identity; indexed = true; is_component = false; no_history = false; doc = None; value_type = None; tuple_attrs = None; tuple_types = None } ] () + |> db_with + [ Add (Entity_id 1, "email", String "ivan@x") + ; Add (Entity_id 1, "ms", Int64 epoch_ms) + ] + in + (match q_string db "[:find ?v . :where [[:email \"ivan@x\"] :ms ?v]]" with + | [ [ Result_value (Int64 value) ] ] -> expect "lookup-ref resolves int64 attr" epoch_ms value + | _ -> failwith "lookup-ref query returned unexpected result"); + (match entity db (Entity_id 1) with + | Some e -> + (match entity_attr e "db/id" with + | Some (One_value (Int64 id)) -> expect "db/id renders as Int64" 1L id + | _ -> failwith "db/id was not Int64") + | None -> failwith "entity lookup failed") + +let () = + test_int64_values_roundtrip (); + test_int64_equality_and_ordering (); + test_int64_predicates (); + test_int64_edn (); + test_int64_query (); + test_int64_transit_codec (); + test_int64_storage_migration (); + test_int64_lookup_ref_and_entity (); + print_endline "test_int64 ok" diff --git a/test/test_issues.ml b/test/test_issues.ml index b23dcaa..113f55b 100644 --- a/test/test_issues.ml +++ b/test/test_issues.ml @@ -62,7 +62,7 @@ let test_issues__issue_330 () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Maksim") - ; "age", One_value (Int 45) + ; "age", One_value (Int64 45L) ; "aka", One_value (Vector [ String "Max Otto von Stierlitz"; String "Jack Ryan" ]) ] } diff --git a/test/test_listen.ml b/test/test_listen.ml index 1c1ea61..7558f2a 100644 --- a/test/test_listen.ml +++ b/test/test_listen.ml @@ -17,7 +17,7 @@ let test_listen__test_listen_bang () = ignore (listen_bang conn "test" (fun report -> reports := !reports @ [ report ])); ignore (transact_bang_string - ~tx_meta:[ "some-metadata", Int 1 ] + ~tx_meta:[ "some-metadata", Int64 1L ] conn "[[:db/add -1 :name \"Dima\"] [:db/add -1 :age 19] @@ -36,11 +36,11 @@ let test_listen__test_listen_bang () = assert_equal_tx_flags "listen reports first observed tx-data like upstream" [ 3, "name", String "Dima", true - ; 3, "age", Int 19, true + ; 3, "age", Int64 19L, true ; 4, "name", String "Evgeny", true ] first.tx_data; - if first.tx_meta <> [ "some-metadata", Int 1 ] then + if first.tx_meta <> [ "some-metadata", Int64 1L ] then failwith "listen should preserve tx metadata for the first observed report"; assert_equal_tx_flags "listen reports replacements and skips no-op retracts like upstream" diff --git a/test/test_logseq_query_planners.ml b/test/test_logseq_query_planners.ml index 1c186b8..ca179b0 100644 --- a/test/test_logseq_query_planners.ml +++ b/test/test_logseq_query_planners.ml @@ -421,7 +421,7 @@ let test_simple_not_uses_relation_antijoin () = List.concat (List.init count (fun index -> let entity = 1_000 + index in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () ] + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () ] @ if index mod 2 = 0 then [ datom ~e:entity ~a:"item/excluded?" ~v:(Bool true) () ] @@ -445,7 +445,7 @@ let test_source_not_uses_relation_antijoin () = let item_datoms = List.init count (fun index -> let entity = 1_000 + index in - datom ~e:entity ~a:"item/value" ~v:(Int index) ()) + datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) ()) in let excluded_datoms = List.filter_map @@ -792,7 +792,7 @@ let test_has_property_with_bound_title_uses_rule_suffix_context () = ; datom ~e:2 ~a:"db/ident" ~v:(Keyword "noise/value") () ] @ List.init count (fun index -> - datom ~e:(100_000 + index) ~a:"noise/value" ~v:(Int index) ())) + datom ~e:(100_000 + index) ~a:"noise/value" ~v:(Int64 (Int64.of_int index)) ())) in match timed "has-property bound title suffix context" 0.250 (fun () -> @@ -1033,7 +1033,7 @@ let test_rule_call_uses_relation_context_for_many_bindings () = (List.concat (List.init count (fun index -> let entity = 1_000 + index in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () ] + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () ] @ if index mod 2 = 0 then [ datom ~e:entity ~a:"item/flag?" ~v:(Bool true) () @@ -1080,7 +1080,7 @@ let test_source_rule_call_uses_relation_context_for_many_bindings () = init_db ~schema:[ "item/value", one ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"item/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"item/value" ~v:(Int64 (Int64.of_int index)) ())) in let source_datoms = List.filter_map @@ -1127,7 +1127,7 @@ let test_top_level_or_uses_relation_context_for_many_bindings () = List.concat (List.init count (fun index -> let entity = 1_000 + index in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () ] + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () ] @ if index mod 2 = 0 then [ datom ~e:entity ~a:"item/a" ~v:(Bool true) () ] @@ -1162,7 +1162,7 @@ let test_top_level_or_join_uses_relation_context_for_many_bindings () = List.concat (List.init count (fun index -> let entity = 1_000 + index in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () ] + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () ] @ if index mod 2 = 0 then [ datom ~e:entity ~a:"item/a" ~v:(Bool true) () ] @@ -1200,8 +1200,8 @@ let test_top_level_or_join_required_uses_relation_context_for_many_bindings () = (List.init count (fun index -> let entity = 1_000 + index in let group = index mod 16 in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () - ; datom ~e:entity ~a:"item/group" ~v:(Int group) () + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () + ; datom ~e:entity ~a:"item/group" ~v:(Int64 (Int64.of_int group)) () ] @ if index mod 2 = 0 then @@ -1250,8 +1250,8 @@ let test_source_or_join_required_uses_relation_context_for_many_bindings () = (List.init count (fun index -> let entity = 1_000 + index in let group = index mod 16 in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () - ; datom ~e:entity ~a:"item/group" ~v:(Int group) () + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () + ; datom ~e:entity ~a:"item/group" ~v:(Int64 (Int64.of_int group)) () ]))) in let source_db = @@ -1261,7 +1261,7 @@ let test_source_or_join_required_uses_relation_context_for_many_bindings () = (List.init count (fun index -> let entity = 1_000 + index in let group = index mod 16 in - [ datom ~e:entity ~a:"item/group" ~v:(Int group) () ] + [ datom ~e:entity ~a:"item/group" ~v:(Int64 (Int64.of_int group)) () ] @ if index mod 2 = 0 then [ datom ~e:entity ~a:"item/a" ~v:(Bool true) () ] @@ -1304,7 +1304,7 @@ let test_top_level_not_join_uses_relation_context_for_many_bindings () = List.concat (List.init count (fun index -> let entity = 1_000 + index in - [ datom ~e:entity ~a:"item/value" ~v:(Int index) () ] + [ datom ~e:entity ~a:"item/value" ~v:(Int64 (Int64.of_int index)) () ] @ if index mod 2 = 0 then [ datom ~e:entity ~a:"item/excluded?" ~v:(Bool true) () ] @@ -1336,7 +1336,7 @@ let test_source_not_join_uses_relation_context_for_many_bindings () = init_db ~schema:[ "item/value", one ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"item/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"item/value" ~v:(Int64 (Int64.of_int index)) ())) in let excluded_db = init_db @@ -1374,11 +1374,11 @@ let test_relation_source_join_uses_relation_context_for_many_bindings () = init_db ~schema:[ "item/value", one ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"item/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"item/value" ~v:(Int64 (Int64.of_int index)) ())) in let labels = List.init count (fun index -> - [ Result_value (Int index) + [ Result_value (Int64 (Int64.of_int index)) ; Result_value (String (Printf.sprintf "label-%d" index)) ]) in @@ -1406,13 +1406,13 @@ let test_input_bound_predicate_uses_relation_rows () = init_db ~schema:[ "score/value", one ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int64 (Int64.of_int index)) ())) in let threshold = 0 in let rows = timed "input-bound predicate relation rows" 0.100 (fun () -> q_sources_string - ~inputs:[ Arg_scalar (Result_value (Int threshold)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 (Int64.of_int threshold))) ] db [] "[:find ?e @@ -1429,7 +1429,7 @@ let test_source_clause_predicate_uses_relation_rows () = init_db ~schema:[ "score/value", one ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int64 (Int64.of_int index)) ())) in let source_db = empty_db () in let query = @@ -1439,7 +1439,7 @@ let test_source_clause_predicate_uses_relation_rows () = ; rules = [] ; where = [ Pattern (QVar "e", QAttr "score/value", QVar "score") - ; SourceClause ("scores", ComparisonPredicate (GreaterThan, QVar "score", QValue (Int 0))) + ; SourceClause ("scores", ComparisonPredicate (GreaterThan, QVar "score", QValue (Int64 0L))) ] } in @@ -1456,7 +1456,7 @@ let test_source_clause_function_uses_relation_rows () = init_db ~schema:[ "score/value", one ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int64 (Int64.of_int index)) ())) in let source_db = empty_db () in let query = @@ -1466,7 +1466,7 @@ let test_source_clause_function_uses_relation_rows () = ; rules = [] ; where = [ Pattern (QVar "e", QAttr "score/value", QVar "score") - ; SourceClause ("scores", ArithmeticValue (AddNumbers, [ QVar "score"; QValue (Int 1) ], "next")) + ; SourceClause ("scores", ArithmeticValue (AddNumbers, [ QVar "score"; QValue (Int64 1L) ], "next")) ] } in @@ -1483,13 +1483,13 @@ let test_input_bound_predicate_uses_index_range () = init_db ~schema:[ "score/value", { one with indexed = true } ] (List.init count (fun index -> - datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int index) ())) + datom ~e:(1_000 + index) ~a:"score/value" ~v:(Int64 (Int64.of_int index)) ())) in let threshold = count - 11 in let rows = timed "input-bound predicate index range" 0.020 (fun () -> q_string - ~inputs:[ Arg_scalar (Result_value (Int threshold)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 (Int64.of_int threshold))) ] db "[:find ?e :in $ ?threshold @@ -1514,7 +1514,7 @@ let test_same_entity_indexed_chain_uses_sparse_candidate_scan () = let entity = 1_000 + index in [ datom ~e:entity ~a:"person/name" ~v:(String (if index mod 8 = 0 then "Ivan" else "Petr")) () ; datom ~e:entity ~a:"person/last-name" ~v:(String (Printf.sprintf "L%d" (index mod 97))) () - ; datom ~e:entity ~a:"person/age" ~v:(Int (index mod 100)) () + ; datom ~e:entity ~a:"person/age" ~v:(Int64 (Int64.of_int (index mod 100))) () ; datom ~e:entity ~a:"person/sex" ~v:(Keyword (if index mod 2 = 0 then "male" else "female")) () ])) in diff --git a/test/test_lookup_refs.ml b/test/test_lookup_refs.ml index 3e0658c..1bcb3a8 100644 --- a/test/test_lookup_refs.ml +++ b/test/test_lookup_refs.ml @@ -24,7 +24,7 @@ let assert_equal_triples label expected actual = let actual = List.map (fun d -> d.e, d.a, d.v) actual in if expected <> actual then let value = function - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | String value -> Printf.sprintf "%S" value | Ref value -> "Ref " ^ string_of_int value | other -> Printf.sprintf "%d" (Hashtbl.hash other) @@ -76,13 +76,13 @@ let lookup_base () = ~db_id:(Entity_id 1) [ one "name" (String "Ivan") ; one "email" (String "@1") - ; one "age" (Int 35) + ; one "age" (Int64 35L) ] ; tx_entity ~db_id:(Entity_id 2) [ one "name" (String "Petr") ; one "email" (String "@2") - ; one "age" (Int 22) + ; one "age" (Int64 22L) ] ] @@ -97,12 +97,12 @@ let test_lookup_refs__test_lookup_refs () = let db = lookup_base () in assert_entity "lookup ref resolves unique identity attr" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] db (Lookup_ref ("name", String "Ivan")); assert_entity "lookup ref resolves unique value attr" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] db (Lookup_ref ("email", String "@1")); assert_entity "missing lookup ref returns no entity" [] db (Lookup_ref ("name", String "Sergey")); @@ -110,7 +110,7 @@ let test_lookup_refs__test_lookup_refs () = assert_raises_invalid_arg_message "lookup ref rejects non-unique attrs" "Lookup ref attribute should be marked as :db/unique: [:age 10]" - (fun () -> ignore (entity db (Lookup_ref ("age", Int 10)))) + (fun () -> ignore (entity db (Lookup_ref ("age", Int64 10L)))) let transact_base () = empty_db ~schema:[ "name", unique_identity; "friend", ref_attr; "friends", ref_many; "age", indexed ] () @@ -128,15 +128,15 @@ let test_lookup_refs__test_lookup_refs_transact () = let oleg = Lookup_ref ("name", String "Oleg") in let db = db - |> db_with [ Add (ivan, "age", Int 35) ] - |> db_with [ tx_entity ~db_id:ivan [ one "age" (Int 36) ] ] + |> db_with [ Add (ivan, "age", Int64 35L) ] + |> db_with [ tx_entity ~db_id:ivan [ one "age" (Int64 36L) ] ] |> db_with [ Add (Entity_id 1, "friend", Ref_to petr) ] |> db_with [ tx_entity ~db_id:(Entity_id 1) [ one "friend" (Ref_to oleg) ] ] |> db_with [ tx_entity ~db_id:(Entity_id 2) [ one "_friend" (Ref_to ivan) ] ] in assert_equal_triples "lookup refs transact through add and entity maps" - [ 1, "age", Int 36 + [ 1, "age", Int64 36L ; 1, "friend", Ref 2 ; 1, "name", String "Ivan" ; 2, "name", String "Petr" @@ -150,7 +150,7 @@ let test_lookup_refs__test_lookup_refs_transact () = |> db_with [ Add (Entity_id 1, "friend", Ref_to oleg) ] |> db_with [ CompareAndSet (ivan, "name", Some (String "Ivan"), String "Vanya") ] |> db_with [ CompareAndSet (Entity_id 1, "friend", Some (Ref_to oleg), Ref_to (Lookup_ref ("name", String "Sergey"))) ] - |> db_with [ Retract (Lookup_ref ("name", String "Vanya"), "age", Some (Int 36)) ] + |> db_with [ Retract (Lookup_ref ("name", String "Vanya"), "age", Some (Int64 36L)) ] |> db_with [ RetractAttr (Lookup_ref ("name", String "Vanya"), "friend") ] in assert_equal_triples @@ -166,12 +166,12 @@ let test_lookup_refs__test_lookup_refs_transact () = assert_raises_invalid_arg_message "lookup refs in add entity position must resolve" "Nothing found for entity id [:name \"Missing\"]" - (fun () -> ignore (db_with [ Add (Lookup_ref ("name", String "Missing"), "age", Int 10) ] (transact_base ()))); + (fun () -> ignore (db_with [ Add (Lookup_ref ("name", String "Missing"), "age", Int64 10L) ] (transact_base ()))); assert_raises_invalid_arg_message "lookup refs in entity-map db/id must resolve" "Nothing found for entity id [:name \"Missing\"]" (fun () -> - ignore (db_with [ tx_entity ~db_id:(Lookup_ref ("name", String "Missing")) [ one "age" (Int 10) ] ] (transact_base ()))) + ignore (db_with [ tx_entity ~db_id:(Lookup_ref ("name", String "Missing")) [ one "age" (Int64 10L) ] ] (transact_base ()))) let test_lookup_refs__test_lookup_refs_transact_multi () = let db = transact_base () in @@ -251,9 +251,9 @@ let test_lookup_refs__lookup_refs_index_access () = let query_base () = empty_db ~schema:[ "name", unique_identity; "friend", ref_attr ] () |> db_with - [ tx_entity ~db_id:(Entity_id 1) [ one "id" (Int 1); one "name" (String "Ivan"); one "age" (Int 11); one "friend" (Ref 2) ] - ; tx_entity ~db_id:(Entity_id 2) [ one "id" (Int 2); one "name" (String "Petr"); one "age" (Int 22); one "friend" (Ref 3) ] - ; tx_entity ~db_id:(Entity_id 3) [ one "id" (Int 3); one "name" (String "Oleg"); one "age" (Int 33) ] + [ tx_entity ~db_id:(Entity_id 1) [ one "id" (Int64 1L); one "name" (String "Ivan"); one "age" (Int64 11L); one "friend" (Ref 2) ] + ; tx_entity ~db_id:(Entity_id 2) [ one "id" (Int64 2L); one "name" (String "Petr"); one "age" (Int64 22L); one "friend" (Ref 3) ] + ; tx_entity ~db_id:(Entity_id 3) [ one "id" (Int64 3L); one "name" (String "Oleg"); one "age" (Int64 33L) ] ] let test_lookup_refs__test_lookup_refs_query () = @@ -268,14 +268,14 @@ let test_lookup_refs__test_lookup_refs_query () = in assert_equal_query_set "q accepts lookup refs as scalar entity inputs and preserves the returned input value" - [ [ Result_value (Ref_to (Lookup_ref ("name", String "Ivan"))); Result_value (Int 11) ] ] + [ [ Result_value (Ref_to (Lookup_ref ("name", String "Ivan"))); Result_value (Int64 11L) ] ] (q ~inputs:[ Arg_scalar (Result_value (Ref_to (Lookup_ref ("name", String "Ivan")))) ] db entity_input_query); let collection_query = { entity_input_query with inputs = [ Input_collection_decl "e" ]; find = [ Find_var "v" ] } in assert_equal_query_set "q resolves lookup refs inside collection inputs" - [ [ Result_value (Int 11) ]; [ Result_value (Int 22) ] ] + [ [ Result_value (Int64 11L) ]; [ Result_value (Int64 22L) ] ] (q ~inputs: [ Arg_collection diff --git a/test/test_parser.ml b/test/test_parser.ml index f38b812..d7d77ca 100644 --- a/test/test_parser.ml +++ b/test/test_parser.ml @@ -167,8 +167,8 @@ let test_parser__aggregate_and_find_arg_helpers () = (Parser.parse_find_arg (QueryFormKeyword "status")); assert_equal "parse_find_args preserves arg order" - [ QVar "name"; QSource "other"; QValue (Int 1) ] - (Parser.parse_find_args [ sym "?name"; sym "$other"; QueryFormInt 1 ]) + [ QVar "name"; QSource "other"; QValue (Int64 1L) ] + (Parser.parse_find_args [ sym "?name"; sym "$other"; QueryFormInt 1L ]) let test_parser__output_var_helpers () = assert_equal_string "parse_output_var preserves placeholders" "_" (Parser.parse_output_var (sym "_")); @@ -313,7 +313,7 @@ let test_parser__pattern_term_helpers () = assert_equal "parse_pattern_term parses entity ids in entity position" (QEntity 42) - (Parser.parse_pattern_term ~entity_position:true (QueryFormInt 42)); + (Parser.parse_pattern_term ~entity_position:true (QueryFormInt 42L)); assert_equal "comparison_predicate_of_symbol parses <" (Some LessThan) (Parser.comparison_predicate_of_symbol "<"); assert_equal "value_predicate_of_symbol parses keyword?" (Some KeywordValue) (Parser.value_predicate_of_symbol "keyword?"); assert_equal "numeric_predicate_of_symbol parses odd?" (Some OddInteger) (Parser.numeric_predicate_of_symbol "odd?"); diff --git a/test/test_parser_find.ml b/test/test_parser_find.ml index 602973b..9b439da 100644 --- a/test/test_parser_find.ml +++ b/test/test_parser_find.ml @@ -6,7 +6,7 @@ let assert_equal label expected actual = if expected <> actual then failf "%s" label let sym name = QueryFormSymbol name -let int value = QueryFormInt value +let int value = QueryFormInt (Int64.of_int value) let vec forms = QueryFormVector forms let list forms = QueryFormList forms @@ -71,7 +71,7 @@ let test_parser_find__test_parse_custom_aggregates () = let test_parser_find__test_parse_find_elements () = assert_equal "aggregate supports constants and source vars" - (Return_scalar, [ Find_aggregate (Count, [ QVar "b"; QValue (Int 1); QSource "x" ]) ]) + (Return_scalar, [ Find_aggregate (Count, [ QVar "b"; QValue (Int64 1L); QSource "x" ]) ]) (Parser.parse_find (vec [ list [ sym "count"; sym "?b"; int 1; sym "$x" ]; sym "." ])) let () = diff --git a/test/test_parser_where.ml b/test/test_parser_where.ml index 949dca8..30317ab 100644 --- a/test/test_parser_where.ml +++ b/test/test_parser_where.ml @@ -17,7 +17,7 @@ let assert_none label = function let sym name = QueryFormSymbol name let kw name = QueryFormKeyword name -let int value = QueryFormInt value +let int value = QueryFormInt (Int64.of_int value) let str value = QueryFormString value let vec forms = QueryFormVector forms let list forms = QueryFormList forms @@ -47,7 +47,7 @@ let test_parser_where__pattern () = let test_parser_where__test_pred () = assert_equal "plain predicate" - (DynamicPredicate ("pred", [ QVar "a"; QValue (Int 1) ])) + (DynamicPredicate ("pred", [ QVar "a"; QValue (Int64 1L) ])) (Parser.parse_clause (vec [ list [ sym "pred"; sym "?a"; int 1 ] ])); assert_equal "plain predicate no args" (DynamicPredicate ("pred", [])) (Parser.parse_clause (vec [ list [ sym "pred" ] ])); assert_equal @@ -58,7 +58,7 @@ let test_parser_where__test_pred () = let test_parser_where__test_fn () = assert_equal "plain function" - (DynamicFunction ("fn", [ QVar "a"; QValue (Int 1) ], [ "x" ])) + (DynamicFunction ("fn", [ QVar "a"; QValue (Int64 1L) ], [ "x" ])) (Parser.parse_clause (vec [ list [ sym "fn"; sym "?a"; int 1 ]; sym "?x" ])); assert_equal "plain function no args" (DynamicFunction ("fn", [], [ "x" ])) (Parser.parse_clause (vec [ list [ sym "fn" ]; sym "?x" ])); assert_equal "custom function" (DynamicFunction ("custom-fn", [], [ "x" ])) (Parser.parse_clause (vec [ list [ sym "?custom-fn" ]; sym "?x" ])); @@ -149,11 +149,11 @@ let test_parser_where__value_function_helper_batch () = ignore (Parser.parse_core_value_function "compare" [ sym "?x" ] "?out")); assert_equal "parse_collection_function parses vectors" - (VectorValue ([ QVar "x"; QValue (Int 1) ], "out")) + (VectorValue ([ QVar "x"; QValue (Int64 1L) ], "out")) (Parser.parse_collection_function "vector" [ sym "?x"; int 1 ] "?out"); assert_equal "parse_collection_function parses ranges" - (RangeStepValue (QValue (Int 1), QValue (Int 5), QValue (Int 2), "out")) + (RangeStepValue (QValue (Int64 1L), QValue (Int64 5L), QValue (Int64 2L), "out")) (Parser.parse_collection_function "range" [ int 1; int 5; int 2 ] "?out"); assert_invalid "parse_collection_function validates hash-map arity" (fun () -> ignore (Parser.parse_collection_function "hash-map" [ kw "a" ] "?out")); @@ -171,11 +171,11 @@ let test_parser_where__value_function_helper_batch () = (Parser.parse_clause (vec [ list [ sym "untuple"; sym "?pages" ]; vec [ sym "?page"; sym "..." ] ])); assert_equal "ground_values_of_form parses tuple ground values" - [ String "a"; Int 1 ] + [ String "a"; Int64 1L ] (Parser.ground_values_of_form (vec [ str "a"; int 1 ])); assert_equal "ground_relation_rows_of_form parses relation ground values" - [ [ String "a"; Int 1 ]; [ String "b"; Int 2 ] ] + [ [ String "a"; Int64 1L ]; [ String "b"; Int64 2L ] ] (Parser.ground_relation_rows_of_form (vec [ vec [ str "a"; int 1 ]; vec [ str "b"; int 2 ] ])); assert_equal "dynamic_ground_term accepts query vars" @@ -187,7 +187,7 @@ let test_parser_where__value_function_helper_batch () = (Parser.parse_ground_function [ sym "?x" ] (sym "?out")); assert_equal "parse_ground_function parses static relation ground" - (GroundRelation ([ [ String "a"; Int 1 ] ], [ "name"; "age" ])) + (GroundRelation ([ [ String "a"; Int64 1L ] ], [ "name"; "age" ])) (Parser.parse_ground_function [ vec [ vec [ str "a"; int 1 ] ] ] (vec [ vec [ sym "?name"; sym "?age" ]; sym "..." ])); @@ -219,15 +219,15 @@ let test_parser_where__string_transform_helper_batch () = (Parser.parse_string_transform_function "clojure.string/replace" [ sym "?s"; str "a"; str "b" ] "?out"); assert_equal "parse_string_transform_function parses split with limit" - (StringSplitLimitValue (QVar "s", QValue (String ","), QValue (Int 2), "out")) + (StringSplitLimitValue (QVar "s", QValue (String ","), QValue (Int64 2L), "out")) (Parser.parse_string_transform_function "clojure.string/split" [ sym "?s"; str ","; int 2 ] "?out"); assert_equal "parse_string_transform_function parses subs without end" - (StringSubstringValue (QVar "s", QValue (Int 1), None, "out")) + (StringSubstringValue (QVar "s", QValue (Int64 1L), None, "out")) (Parser.parse_string_transform_function "subs" [ sym "?s"; int 1 ] "?out"); assert_equal "parse_string_transform_function parses subs with end" - (StringSubstringValue (QVar "s", QValue (Int 1), Some (QValue (Int 3)), "out")) + (StringSubstringValue (QVar "s", QValue (Int64 1L), Some (QValue (Int64 3L)), "out")) (Parser.parse_string_transform_function "subs" [ sym "?s"; int 1; int 3 ] "?out"); assert_equal "parse_string_transform_function falls through to metadata/value functions" diff --git a/test/test_perf.ml b/test/test_perf.ml index c3eb76f..98462b3 100644 --- a/test/test_perf.ml +++ b/test/test_perf.ml @@ -40,10 +40,10 @@ let person i = Entity { db_id = Some (Entity_id i) ; attrs = - [ "id", One_value (Int i) + [ "id", One_value (Int64 (Int64.of_int i)) ; "name", One_value (String names.((i - 1) mod Array.length names)) - ; "age", One_value (Int ((i * 37) mod 100)) - ; "salary", One_value (Int ((i * 7919) mod 100_000)) + ; "age", One_value (Int64 (Int64.of_int ((i * 37) mod 100))) + ; "salary", One_value (Int64 (Int64.of_int ((i * 7919) mod 100_000))) ; "sex", One_value (Keyword (if i mod 2 = 0 then "male" else "female")) ; "alias", Many_values [ String ("alias-" ^ string_of_int (i mod 10)); String ("tag-" ^ string_of_int (i mod 17)) ] ] diff --git a/test/test_pull_api.ml b/test/test_pull_api.ml index 642fde8..5eac756 100644 --- a/test/test_pull_api.ml +++ b/test/test_pull_api.ml @@ -74,7 +74,7 @@ let test_db () = let rec string_of_value = function | Nil -> "nil" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> Printf.sprintf "%S" value | Symbol value -> value @@ -167,7 +167,7 @@ let test_pull_api__test_pull_reverse_attr_spec () = db [ Pull_attr "name"; Pull_reverse_ref ("child", [ Pull_id ]) ] (Entity_id 2) - [ kw "child", many_values [ entity 1 [ kw "db/id", scalar (Int 1) ] ] + [ kw "child", many_values [ entity 1 [ kw "db/id", scalar (Int64 1L) ] ] ; kw "name", scalar (String "David") ]; expect_pull @@ -204,7 +204,7 @@ let test_pull_api__test_pull_component_attr () = let test_pull_api__test_pull_wildcard () = let db = test_db () in match Pull_api.pull db [ Pull_wildcard ] (Entity_id 1) with - | Some entity when List.assoc_opt (kw "db/id") entity.pulled_attrs = Some (scalar (Int 1)) + | Some entity when List.assoc_opt (kw "db/id") entity.pulled_attrs = Some (scalar (Int64 1L)) && List.assoc_opt (kw "name") entity.pulled_attrs = Some (scalar (String "Petr")) -> () | _ -> failf "wildcard pull should include db/id and attrs" diff --git a/test/test_pull_parser.ml b/test/test_pull_parser.ml index 0f7e80e..29aff39 100644 --- a/test/test_pull_parser.ml +++ b/test/test_pull_parser.ml @@ -36,7 +36,7 @@ let db = let sym name = QueryFormSymbol name let kw name = QueryFormKeyword name let str value = QueryFormString value -let int value = QueryFormInt value +let int value = QueryFormInt (Int64.of_int value) let vec forms = QueryFormVector forms let list forms = QueryFormList forms let map entries = QueryFormMap entries diff --git a/test/test_query_engine_fixes.ml b/test/test_query_engine_fixes.ml index 35fdeb6..4c99c7a 100644 --- a/test/test_query_engine_fixes.ml +++ b/test/test_query_engine_fixes.ml @@ -291,14 +291,14 @@ let test_predicate_over_in_scalar () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "attr", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "attr", One_value (Int 2) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "attr", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "attr", One_value (Int64 2L) ] } ] in assert_rows "[(= ?v ?target)] filters by :in binding" [ [ Result_entity 2 ] ] - (q_string ~inputs:[ Arg_scalar (Result_value (Int 2)) ] db + (q_string ~inputs:[ Arg_scalar (Result_value (Int64 2L)) ] db "[:find ?e :in $ ?target :where [?e :attr ?v] [(= ?v ?target)]]") (* Bug 3: collection-form :in binds each element *) @@ -306,15 +306,15 @@ let test_collection_in_binding () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "attr", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "attr", One_value (Int 2) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "attr", One_value (Int 3) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "attr", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "attr", One_value (Int64 2L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "attr", One_value (Int64 3L) ] } ] in assert_rows "[?x ...] collection :in iterates elements" [ [ Result_entity 1 ]; [ Result_entity 3 ] ] - (q_string ~inputs:[ Arg_collection [ Result_value (Int 1); Result_value (Int 3) ] ] db + (q_string ~inputs:[ Arg_collection [ Result_value (Int64 1L); Result_value (Int64 3L) ] ] db "[:find ?e :in $ [?x ...] :where [?e :attr ?x]]") (* Bug 2 extended: comparison predicates over :in-bound vars *) @@ -322,20 +322,20 @@ let test_comparison_predicates_over_in () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "d", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "d", One_value (Int 3) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "d", One_value (Int 5) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "d", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "d", One_value (Int64 3L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "d", One_value (Int64 5L) ] } ] in assert_rows "[(<= ?d ?cutoff)] filters by :in binding" [ [ Result_entity 1 ]; [ Result_entity 2 ] ] - (q_string ~inputs:[ Arg_scalar (Result_value (Int 3)) ] db + (q_string ~inputs:[ Arg_scalar (Result_value (Int64 3L)) ] db "[:find ?e :in $ ?cutoff :where [?e :d ?d] [(<= ?d ?cutoff)]]"); assert_rows "[(not= ?d ?x)] filters by :in binding" [ [ Result_entity 1 ]; [ Result_entity 3 ] ] - (q_string ~inputs:[ Arg_scalar (Result_value (Int 3)) ] db + (q_string ~inputs:[ Arg_scalar (Result_value (Int64 3L)) ] db "[:find ?e :in $ ?x :where [?e :d ?d] [(not= ?d ?x)]]") (* Bug 2 extended: predicate over collection-bound :in var sees each element *) @@ -343,14 +343,14 @@ let test_predicate_over_collection_in () = let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "attr", One_value (Int 1) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "attr", One_value (Int 3) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "attr", One_value (Int64 1L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "attr", One_value (Int64 3L) ] } ] in assert_rows "[(= ?v ?x)] sees collection :in elements" [ [ Result_entity 1 ]; [ Result_entity 2 ] ] - (q_string ~inputs:[ Arg_collection [ Result_value (Int 1); Result_value (Int 3) ] ] db + (q_string ~inputs:[ Arg_collection [ Result_value (Int64 1L); Result_value (Int64 3L) ] ] db "[:find ?e :in $ [?x ...] :where [?e :attr ?v] [(= ?v ?x)]]") (* Bug 5: lookup refs inside a transaction resolve against the db with the @@ -818,7 +818,7 @@ let logseq_rule_db () = [ "block/title", One_value (String "Page1") ; "block/tags", Many_values [ Keyword "user.class/Person" ] ; "user.property/foo", One_value (String "bar") - ; "user.property/number-many", Many_values [ Int 5; Int 10 ] + ; "user.property/number-many", Many_values [ Int64 5L; Int64 10L ] ; "user.property/page-many", Many_values [ Keyword "logseq.class/Page" ] ] } @@ -921,7 +921,7 @@ let test_rule_tags_query_with_eid_input () = (q_string db ~inputs: [ Arg_rules (rules_of_string logseq_dsl_rules) - ; Arg_scalar (Result_value (Set [ Int 17 ])) + ; Arg_scalar (Result_value (Set [ Int64 17L ])) ] "[:find ?b :in $ % ?tag-ids :where (tags ?b ?tag-ids)]") diff --git a/test/test_query_namespace.ml b/test/test_query_namespace.ml index d6a6933..f30f878 100644 --- a/test/test_query_namespace.ml +++ b/test/test_query_namespace.ml @@ -165,7 +165,7 @@ let test_query_namespace__test_query_result_helpers () = assert_equal_int_option "entity_id_of_resolved_query_result validates integer results" (Some 43) - (Query.entity_id_of_resolved_query_result ~validate_entity_id (Some (Result_value (Int 43)))); + (Query.entity_id_of_resolved_query_result ~validate_entity_id (Some (Result_value (Int64 43L)))); assert_equal_int_option "entity_id_of_resolved_query_result accepts ref values" (Some 44) @@ -179,7 +179,7 @@ let test_query_namespace__test_query_result_helpers () = None (Query.entity_id_of_resolved_query_result ~validate_entity_id None); assert_raises_invalid_arg "entity_id_of_resolved_query_result validates integer ids" (fun () -> - ignore (Query.entity_id_of_resolved_query_result ~validate_entity_id (Some (Result_value (Int 0))))); + ignore (Query.entity_id_of_resolved_query_result ~validate_entity_id (Some (Result_value (Int64 0L))))); assert_equal_query_option "resolved_query_result resolves value results through the context" (Some (Result_entity 42)) @@ -493,12 +493,12 @@ let test_query_namespace__test_source_matching_helpers () = (fun () -> ignore (Query.source_db root_db [ "rows", Relation_source [] ] "rows")); assert_equal_query_option "match_relation_row binds each relation column" - (Some [ "age", Result_value (Int 42); "name", Result_value (String "Ivan") ]) + (Some [ "age", Result_value (Int64 42L); "name", Result_value (String "Ivan") ]) (Query.match_relation_row source_context [] [ QVar "name"; QVar "age" ] - [ Result_value (String "Ivan"); Result_value (Int 42) ]); + [ Result_value (String "Ivan"); Result_value (Int64 42L) ]); assert_raises_invalid_arg_message "match_relation_row rejects short rows" "source relation row arity mismatch" @@ -573,9 +573,9 @@ let test_query_namespace__test_aggregate_helpers () = (MinN 2) (Query.resolve_dynamic_aggregate (MinNVar "n") - [ [ "n", Result_value (Int 2); "amount", Result_value (Int 10) ] ]); + [ [ "n", Result_value (Int64 2L); "amount", Result_value (Int64 10L) ] ]); assert_raises_invalid_arg "dynamic aggregate amount must be non-negative" (fun () -> - ignore (Query.resolve_dynamic_aggregate (SampleVar "n") [ [ "n", Result_value (Int (-1)) ] ])); + ignore (Query.resolve_dynamic_aggregate (SampleVar "n") [ [ "n", Result_value (Int64 (-1L)) ] ])); assert_raises_invalid_arg "dynamic aggregate amount must be bound" (fun () -> ignore (Query.resolve_dynamic_aggregate (MaxNVar "n") [])); assert_equal_string_list @@ -594,18 +594,18 @@ let test_query_namespace__test_aggregate_helpers () = ignore (Query.split_aggregate_terms [])); assert_equal_query_row "custom aggregate receives extra args before values" - [ Result_value (Int 9); Result_value (Int 1); Result_value (Int 2) ] + [ Result_value (Int64 9L); Result_value (Int64 1L); Result_value (Int64 2L) ] (Query.aggregate_input_values - (Custom (fun values -> Result_value (Int (List.length values)))) - [ Result_value (Int 9) ] - [ Result_value (Int 1); Result_value (Int 2) ]); + (Custom (fun values -> Result_value (Int64 (Int64.of_int (List.length values))))) + [ Result_value (Int64 9L) ] + [ Result_value (Int64 1L); Result_value (Int64 2L) ]); assert_equal_query_row "built-in aggregate ignores extra args after parse-time resolution" - [ Result_value (Int 1); Result_value (Int 2) ] + [ Result_value (Int64 1L); Result_value (Int64 2L) ] (Query.aggregate_input_values Sum - [ Result_value (Int 9) ] - [ Result_value (Int 1); Result_value (Int 2) ]); + [ Result_value (Int64 9L) ] + [ Result_value (Int64 1L); Result_value (Int64 2L) ]); let match_context = { Query.result_resolution_context = { validate_entity_id = (fun entity_id -> entity_id) @@ -661,30 +661,30 @@ let test_query_namespace__test_aggregate_helpers () = match_context default_db sources - [ [ "n", Result_value (Int 2); "amount", Result_value (Int 10) ] - ; [ "n", Result_value (Int 3); "amount", Result_value (Int 20) ] + [ [ "n", Result_value (Int64 2L); "amount", Result_value (Int64 10L) ] + ; [ "n", Result_value (Int64 3L); "amount", Result_value (Int64 20L) ] ] [ QVar "n"; QSource "other"; QVar "amount" ] with - | [ Result_value (Int 2); Result_db db ] when db == other_db -> () + | [ Result_value (Int64 2L); Result_db db ] when db == other_db -> () | _ -> failwith "aggregate_extra_args should use first group binding and resolve source args"); assert_equal_query_row "aggregate_values evaluates the aggregate value term for every group binding" - [ Result_value (Int 10); Result_value (Int 20) ] + [ Result_value (Int64 10L); Result_value (Int64 20L) ] (Query.aggregate_values match_context default_db sources - [ [ "amount", Result_value (Int 10) ]; [ "amount", Result_value (Int 20) ] ] + [ [ "amount", Result_value (Int64 10L) ]; [ "amount", Result_value (Int64 20L) ] ] [ QVar "amount" ]); assert_equal_query_row "aggregate_values drops bindings where the value term is unbound" - [ Result_value (Int 10) ] + [ Result_value (Int64 10L) ] (Query.aggregate_values match_context default_db sources - [ [ "amount", Result_value (Int 10) ]; [ "name", Result_value (String "missing") ] ] + [ [ "amount", Result_value (Int64 10L) ]; [ "name", Result_value (String "missing") ] ] [ QVar "amount" ]); assert_raises_invalid_arg_message "aggregate_extra_args rejects unbound extra args" @@ -695,19 +695,19 @@ let test_query_namespace__test_aggregate_helpers () = match_context default_db sources - [ [ "amount", Result_value (Int 10) ] ] + [ [ "amount", Result_value (Int64 10L) ] ] [ QVar "missing"; QVar "amount" ])) let test_query_namespace__test_find_grouping_helpers () = let binding = [ "name", Result_value (String "Ivan") - ; "age", Result_value (Int 30) + ; "age", Result_value (Int64 30L) ; "city", Result_value (String "Berlin") ] in assert_equal_query_option "collect_find_vars preserves requested order" - (Some [ Result_value (Int 30); Result_value (String "Ivan") ]) + (Some [ Result_value (Int64 30L); Result_value (String "Ivan") ]) (Query.collect_find_vars binding [ "age"; "name" ]); assert_equal_query_option "collect_find_vars returns None when a requested var is missing" @@ -716,14 +716,14 @@ let test_query_namespace__test_find_grouping_helpers () = assert_equal_grouped_bindings "group_by_key prepends later rows in the same group" [ ( [ Result_value (String "Ivan") ] - , [ [ "age", Result_value (Int 31) ]; [ "age", Result_value (Int 30) ] ] ) + , [ [ "age", Result_value (Int64 31L) ]; [ "age", Result_value (Int64 30L) ] ] ) ; ( [ Result_value (String "Oleg") ] - , [ [ "age", Result_value (Int 40) ] ] ) + , [ [ "age", Result_value (Int64 40L) ] ] ) ] (Query.group_by_key - [ [ Result_value (String "Ivan") ], [ "age", Result_value (Int 30) ] - ; [ Result_value (String "Oleg") ], [ "age", Result_value (Int 40) ] - ; [ Result_value (String "Ivan") ], [ "age", Result_value (Int 31) ] + [ [ Result_value (String "Ivan") ], [ "age", Result_value (Int64 30L) ] + ; [ Result_value (String "Oleg") ], [ "age", Result_value (Int64 40L) ] + ; [ Result_value (String "Ivan") ], [ "age", Result_value (Int64 31L) ] ]); assert_equal_string_list "grouping_vars_of_find includes non-aggregate find vars" @@ -778,16 +778,16 @@ let test_query_namespace__test_input_shape_helpers () = (Query.values_of_collection_result (Result_value (Vector [ String "a"; String "b" ]))); assert_equal_query_option "values_of_collection_result drops tuple nil slots" - (Some [ Result_value (Int 1); Result_value (Int 3) ]) - (Query.values_of_collection_result (Result_value (Tuple [ Some (Int 1); None; Some (Int 3) ]))); + (Some [ Result_value (Int64 1L); Result_value (Int64 3L) ]) + (Query.values_of_collection_result (Result_value (Tuple [ Some (Int64 1L); None; Some (Int64 3L) ]))); assert_equal_query_option "values_of_collection_result rejects scalar values" None (Query.values_of_collection_result (Result_value (String "not-a-collection"))); assert_equal_query_row "row_of_collection_result preserves tuple nil slots" - [ Result_value (Int 1); Result_value Nil; Result_value (Int 3) ] - (Query.row_of_collection_result (Result_value (Tuple [ Some (Int 1); None; Some (Int 3) ]))); + [ Result_value (Int64 1L); Result_value Nil; Result_value (Int64 3L) ] + (Query.row_of_collection_result (Result_value (Tuple [ Some (Int64 1L); None; Some (Int64 3L) ]))); assert_equal_query_row "row_of_collection_result wraps scalar values" [ Result_value (String "scalar") ] @@ -800,11 +800,11 @@ let test_query_namespace__test_input_shape_helpers () = ignore (Query.row_of_scalar_sequence (Result_value (Keyword "value")))); assert_equal_query_rows "rows_of_map_entries converts map entries to relation rows" - [ [ Result_value (Keyword "a"); Result_value (Int 1) ] - ; [ Result_value (Keyword "b"); Result_value (Vector [ Int 2; Int 3 ]) ] + [ [ Result_value (Keyword "a"); Result_value (Int64 1L) ] + ; [ Result_value (Keyword "b"); Result_value (Vector [ Int64 2L; Int64 3L ]) ] ] (Query.rows_of_map_entries - [ Keyword "a", Int 1; Keyword "b", Vector [ Int 2; Int 3 ] ]) + [ Keyword "a", Int64 1L; Keyword "b", Vector [ Int64 2L; Int64 3L ] ]) let test_query_namespace__test_input_binding_helpers () = let input_context = @@ -830,12 +830,12 @@ let test_query_namespace__test_input_binding_helpers () = in assert_equal_query_option "bind_relation_row binds relation columns" - (Some [ "age", Result_value (Int 30); "name", Result_value (String "Ivan") ]) + (Some [ "age", Result_value (Int64 30L); "name", Result_value (String "Ivan") ]) (Query.bind_relation_row input_context [] [ "name"; "age" ] - [ Result_value (String "Ivan"); Result_value (Int 30) ]); + [ Result_value (String "Ivan"); Result_value (Int64 30L) ]); assert_raises_invalid_arg_message "bind_relation_row rejects row arity mismatch" "relation input row arity mismatch" @@ -850,16 +850,16 @@ let test_query_namespace__test_input_binding_helpers () = (Query.apply_query_input input_context [ [] ] (Input_entity_ref ("e", Ident "known"))); assert_equal_query_rows "apply_query_input expands relation inputs" - [ [ "age", Result_value (Int 30); "name", Result_value (String "Ivan") ] - ; [ "age", Result_value (Int 40); "name", Result_value (String "Oleg") ] + [ [ "age", Result_value (Int64 30L); "name", Result_value (String "Ivan") ] + ; [ "age", Result_value (Int64 40L); "name", Result_value (String "Oleg") ] ] (Query.apply_query_input input_context [ [] ] (Input_relation ( [ "name"; "age" ] - , [ [ Result_value (String "Ivan"); Result_value (Int 30) ] - ; [ Result_value (String "Oleg"); Result_value (Int 40) ] + , [ [ Result_value (String "Ivan"); Result_value (Int64 30L) ] + ; [ Result_value (String "Oleg"); Result_value (Int64 40L) ] ] ))); let query_input_of_arg decl arg = match decl, arg with @@ -879,11 +879,11 @@ let test_query_namespace__test_input_binding_helpers () = [ Arg_scalar (Result_value (String "Ivan")) ]); assert_equal_inputs "bind_query_inputs preserves already bound inputs" - [ Input_collection_ignore [ Result_value (Int 1) ]; Input_ignore ] + [ Input_collection_ignore [ Result_value (Int64 1L) ]; Input_ignore ] (Query.bind_query_inputs ~query_input_of_arg ~consume_rules:false - [ Input_collection_ignore [ Result_value (Int 1) ]; Input_ignore_decl ] + [ Input_collection_ignore [ Result_value (Int64 1L) ]; Input_ignore_decl ] [ Arg_scalar (Result_value (String "ignored")) ]); assert_equal_inputs "bind_query_inputs skips rules declarations when rules are implicit" @@ -918,15 +918,15 @@ let test_query_namespace__test_input_binding_helpers () = let test_query_namespace__test_callable_helpers () = let predicate = function - | [ Result_value (Int value) ] -> value > 10 + | [ Result_value (Int64 value) ] -> value > 10L | _ -> false in let query_function = function - | [ Result_value (Int value) ] -> Some [ Result_value (Int (value + 1)) ] + | [ Result_value (Int64 value) ] -> Some [ Result_value (Int64 (Int64.add value 1L)) ] | _ -> None in let aggregate = function - | values -> Result_value (Int (List.length values)) + | values -> Result_value (Int64 (Int64.of_int (List.length values))) in let callables = Query.empty_query_callables @@ -937,16 +937,16 @@ let test_query_namespace__test_callable_helpers () = in (match Query.callable_predicate callables "bigger?" with | Some f -> - if not (f [ Result_value (Int 11) ]) then failwith "callable_predicate should resolve aliases" + if not (f [ Result_value (Int64 11L) ]) then failwith "callable_predicate should resolve aliases" | None -> failwith "callable_predicate should find aliased predicates"); (match Query.callable_function callables "inc" with | Some f -> - if f [ Result_value (Int 1) ] <> Some [ Result_value (Int 2) ] then + if f [ Result_value (Int64 1L) ] <> Some [ Result_value (Int64 2L) ] then failwith "callable_function should return stored functions" | None -> failwith "callable_function should find stored functions"); (match Query.resolve_callable_aggregate callables (CustomVar "count-values") with | Custom f -> - if f [ Result_value (Int 1); Result_value (Int 2) ] <> Result_value (Int 2) then + if f [ Result_value (Int64 1L); Result_value (Int64 2L) ] <> Result_value (Int64 2L) then failwith "resolve_callable_aggregate should return stored aggregate functions" | _ -> failwith "resolve_callable_aggregate should resolve custom aggregate variables"); if not (Query.has_callable callables "bigger?") then failwith "has_callable should resolve aliases"; @@ -988,16 +988,16 @@ let test_query_namespace__test_rule_helpers () = ignore (Query.matching_rules_exn [ parent_1 ] "missing" 1)); assert_equal_grouped_bindings "project_binding keeps only requested vars" - [ [ "name", Result_value (String "Ivan"); "age", Result_value (Int 30) ] ] + [ [ "name", Result_value (String "Ivan"); "age", Result_value (Int64 30L) ] ] [ Query.project_binding [ "name"; "age" ] [ "name", Result_value (String "Ivan") ; "city", Result_value (String "Berlin") - ; "age", Result_value (Int 30) + ; "age", Result_value (Int64 30L) ] ]; let predicate = function - | [ Result_value (Int value) ] -> value > 10 + | [ Result_value (Int64 value) ] -> value > 10L | _ -> false in let callables = @@ -1406,7 +1406,7 @@ let test_query_namespace__test_query_string_helpers () = | String value -> "\"" ^ value ^ "\"" | Keyword value -> ":" ^ value | Bool value -> if value then "true" else "false" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | value -> failf "unexpected value in test printer: %s" (string_of_int (Hashtbl.hash value)) in assert_equal_string @@ -1452,7 +1452,7 @@ let test_query_namespace__test_query_clause_string_helpers () = | String value -> "\"" ^ value ^ "\"" | Keyword value -> ":" ^ value | Bool value -> if value then "true" else "false" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | value -> failf "unexpected value in test printer: %s" (string_of_int (Hashtbl.hash value)) in assert_equal_string @@ -1518,7 +1518,7 @@ let test_query_namespace__test_binding_validation_helpers () = | String value -> "\"" ^ value ^ "\"" | Keyword value -> ":" ^ value | Bool value -> if value then "true" else "false" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | value -> failf "unexpected value in test printer: %s" (string_of_int (Hashtbl.hash value)) in let binding = [ "e", Result_entity 1 ] in diff --git a/test/test_query_pull.ml b/test/test_query_pull.ml index 1b43e52..942d38d 100644 --- a/test/test_query_pull.ml +++ b/test/test_query_pull.ml @@ -19,9 +19,9 @@ let many_values values = Pulled_many values let db = empty_db () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 44) ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 25) ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int 11) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 44L) ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 25L) ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "age", One_value (Int64 11L) ] } ] let test_query_pull__test_basics () = @@ -31,8 +31,8 @@ let test_query_pull__test_basics () = (q_string db "[:find (pull ?e [:name]) :where [?e :age ?a] [(>= ?a 18)]]"); assert_query_set "pull can be mixed with scalars" - [ [ Result_entity 1; Result_value (Int 44); pull 1 [ kw "name", scalar (String "Petr") ] ] - ; [ Result_entity 2; Result_value (Int 25); pull 2 [ kw "name", scalar (String "Ivan") ] ] + [ [ Result_entity 1; Result_value (Int64 44L); pull 1 [ kw "name", scalar (String "Petr") ] ] + ; [ Result_entity 2; Result_value (Int64 25L); pull 2 [ kw "name", scalar (String "Ivan") ] ] ] (q_string db "[:find ?e ?a (pull ?e [:name]) :where [?e :age ?a] [(>= ?a 18)]]") @@ -46,8 +46,8 @@ let test_query_pull__test_var_pattern () = "[:find (pull ?e ?pattern) :in $ ?pattern :where [?e :age ?a] [(>= ?a 18)]]") let test_query_pull__test_multiple_sources () = - let db1 = empty_db () |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int 25) ] } ] in - let db2 = empty_db () |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 25) ] } ] in + let db1 = empty_db () |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Ivan"); "age", One_value (Int64 25L) ] } ] in + let db2 = empty_db () |> db_with [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 25L) ] } ] in assert_query_set "pull from named source" [ [ Result_entity 1; pull 1 [ kw "name", scalar (String "Ivan") ] ] ] @@ -78,16 +78,16 @@ let test_query_pull__test_aggregates () = let db = empty_db ~schema:[ "value", value_many ] () |> db_with - [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "value", Many_values [ Int 10; Int 20; Int 30; Int 40 ] ] } - ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "value", Many_values [ Int 14; Int 16 ] ] } - ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "value", One_value (Int 1) ] } + [ Entity { db_id = Some (Entity_id 1); attrs = [ "name", One_value (String "Petr"); "value", Many_values [ Int64 10L; Int64 20L; Int64 30L; Int64 40L ] ] } + ; Entity { db_id = Some (Entity_id 2); attrs = [ "name", One_value (String "Ivan"); "value", Many_values [ Int64 14L; Int64 16L ] ] } + ; Entity { db_id = Some (Entity_id 3); attrs = [ "name", One_value (String "Oleg"); "value", One_value (Int64 1L) ] } ] in assert_query_set "pull with aggregates" - [ [ Result_entity 1; pull 1 [ kw "name", scalar (String "Petr") ]; Result_value (Int 10); Result_value (Int 40) ] - ; [ Result_entity 2; pull 2 [ kw "name", scalar (String "Ivan") ]; Result_value (Int 14); Result_value (Int 16) ] - ; [ Result_entity 3; pull 3 [ kw "name", scalar (String "Oleg") ]; Result_value (Int 1); Result_value (Int 1) ] + [ [ Result_entity 1; pull 1 [ kw "name", scalar (String "Petr") ]; Result_value (Int64 10L); Result_value (Int64 40L) ] + ; [ Result_entity 2; pull 2 [ kw "name", scalar (String "Ivan") ]; Result_value (Int64 14L); Result_value (Int64 16L) ] + ; [ Result_entity 3; pull 3 [ kw "name", scalar (String "Oleg") ]; Result_value (Int64 1L); Result_value (Int64 1L) ] ] (q_string db "[:find ?e (pull ?e [:name]) (min ?v) (max ?v) :where [?e :value ?v]]") @@ -98,8 +98,8 @@ let test_query_pull__test_lookup_refs () = in assert_query_set "pull accepts lookup refs in query inputs" - [ [ Result_value (Vector [ Keyword "name"; String "Petr" ]); Result_value (Int 44); pull 1 [ kw "db/id", scalar (Int 1); kw "name", scalar (String "Petr") ] ] - ; [ Result_value (Vector [ Keyword "name"; String "Ivan" ]); Result_value (Int 25); pull 2 [ kw "db/id", scalar (Int 2); kw "name", scalar (String "Ivan") ] ] + [ [ Result_value (Vector [ Keyword "name"; String "Petr" ]); Result_value (Int64 44L); pull 1 [ kw "db/id", scalar (Int64 1L); kw "name", scalar (String "Petr") ] ] + ; [ Result_value (Vector [ Keyword "name"; String "Ivan" ]); Result_value (Int64 25L); pull 2 [ kw "db/id", scalar (Int64 2L); kw "name", scalar (String "Ivan") ] ] ] (q_string ~inputs: @@ -182,7 +182,7 @@ let test_query_pull__test_simple_pull_uses_ref_ident_pattern () = | Query_relation rows -> assert_query_set "simple pull query resolves keyword ident in ref value pattern" - [ [ pull 1 [ kw "db/id", scalar (Int 1) ] ]; [ pull 3 [ kw "db/id", scalar (Int 3) ] ] ] + [ [ pull 1 [ kw "db/id", scalar (Int64 1L) ] ]; [ pull 3 [ kw "db/id", scalar (Int64 3L) ] ] ] rows | _ -> failf "simple pull query should return a relation") diff --git a/test/test_serialize.ml b/test/test_serialize.ml index 71aa8a6..e0a114d 100644 --- a/test/test_serialize.ml +++ b/test/test_serialize.ml @@ -72,7 +72,7 @@ let test_serialize__test_pr_read () = in assert_equal_datoms "db_from_reader_string restores active datoms from #datascript/DB" - [ datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int 44) () + [ datom ~tx:(tx0 + 1) ~e:1 ~a:"age" ~v:(Int64 44L) () ; datom ~tx:(tx0 + 1) ~e:1 ~a:"name" ~v:(String "Petr") () ; datom ~tx:(tx0 + 2) ~e:2 ~a:"friend" ~v:(Ref 1) () ; datom ~e:3 ~a:"name" ~v:(String "DefaultTx") () @@ -86,10 +86,10 @@ let test_serialize__test_init_db () = [ datom ~e:1 ~a:"name" ~v:(String "Petr") () ; datom ~e:1 ~a:"aka" ~v:(String "Devil") () ; datom ~e:1 ~a:"aka" ~v:(String "Tupen") () - ; datom ~e:1 ~a:"age" ~v:(Int 15) () + ; datom ~e:1 ~a:"age" ~v:(Int64 15L) () ; datom ~e:1 ~a:"follows" ~v:(Ref 2) () ; datom ~e:2 ~a:"name" ~v:(String "Oleg") () - ; datom ~e:2 ~a:"age" ~v:(Int 30) () + ; datom ~e:2 ~a:"age" ~v:(Int64 30L) () ; datom ~e:30 ~a:"url" ~v:(String "https://") () ] in @@ -101,10 +101,10 @@ let test_serialize__test_init_db () = [ Add (Entity_id 1, "name", String "Petr") ; Add (Entity_id 1, "aka", String "Devil") ; Add (Entity_id 1, "aka", String "Tupen") - ; Add (Entity_id 1, "age", Int 15) + ; Add (Entity_id 1, "age", Int64 15L) ; Add (Entity_id 1, "follows", Ref 2) ; Add (Entity_id 2, "name", String "Oleg") - ; Add (Entity_id 2, "age", Int 30) + ; Add (Entity_id 2, "age", Int64 30L) ; Add (Entity_id 30, "url", String "https://") ] in diff --git a/test/test_sqlite_storage.ml b/test/test_sqlite_storage.ml index 58c6e22..e086d8b 100644 --- a/test/test_sqlite_storage.ml +++ b/test/test_sqlite_storage.ml @@ -196,7 +196,7 @@ let assert_equal_query label expected actual = let rec string_of_value = function | Nil -> "nil" - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Float value -> string_of_float value | String value -> Printf.sprintf "%S" value | Symbol value -> value @@ -410,7 +410,7 @@ let create_block_tx state revision = ] ) ; "block/tags", Many_values [ Ref (property_id state) ] ; "property/status", One_value (Keyword (random_choice state [| "todo"; "doing"; "done" |])) - ; "property/priority", One_value (Int (1 + Random.State.int state 5)) + ; "property/priority", One_value (Int64 (Int64.of_int (1 + Random.State.int state 5))) ; "property/labels", Many_values [ label_value state ] ] } @@ -438,8 +438,8 @@ let update_block_tx state revision = ] | 4 -> [ Add (Entity_id block, "property/status", Keyword (random_choice state [| "todo"; "doing"; "done"; "blocked" |])) - ; Add (Entity_id block, "property/priority", Int (1 + Random.State.int state 5)) - ; Add (Entity_id block, "property/estimate", Int (Random.State.int state 21)) + ; Add (Entity_id block, "property/priority", Int64 (Int64.of_int (1 + Random.State.int state 5))) + ; Add (Entity_id block, "property/estimate", Int64 (Int64.of_int (Random.State.int state 21))) ] | 5 -> [ Add (Entity_id block, "property/reviewer", Ref (block_id state)) @@ -708,12 +708,12 @@ let test_sqlite_storage_raw_layout_after_transact () = (transact_conn conn ([ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 15) + ; Add (Entity_id 1, "age", Int64 15L) ; Add (Entity_id 1, "aka", String "Devil") ; Add (Entity_id 1, "aka", String "Tupen") ; Add (Entity_id 1, "friend", Ref 2) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 37) + ; Add (Entity_id 2, "age", Int64 37L) ] @ List.init 40 (fun index -> Add (Entity_id 1, "tag", String ("tag-" ^ string_of_int index))))); @@ -882,12 +882,12 @@ let test_sqlite_storage_backed_connections_query_and_transact_after_restore () = (transact_conn conn [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 15) + ; Add (Entity_id 1, "age", Int64 15L) ; Add (Entity_id 1, "aka", String "Devil") ; Add (Entity_id 1, "aka", String "Tupen") ; Add (Entity_id 1, "friend", Ref 2) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 37) + ; Add (Entity_id 2, "age", Int64 37L) ]); let restored = match restore_conn storage with @@ -918,7 +918,7 @@ let test_sqlite_storage_backed_connections_query_and_transact_after_restore () = ignore (transact_conn restored - [ Add (Lookup_ref ("name", String "Ivan"), "age", Int 16) + [ Add (Lookup_ref ("name", String "Ivan"), "age", Int64 16L) ; Retract (Entity_id 1, "aka", Some (String "Devil")) ]); let restored_again = @@ -928,7 +928,7 @@ let test_sqlite_storage_backed_connections_query_and_transact_after_restore () = in assert_equal_query "SQLite storage persists lookup-ref transact after restore" - [ [ Result_entity 1; Result_value (Int 16) ] ] + [ [ Result_entity 1; Result_value (Int64 16L) ] ] (q_string restored_again "[:find ?e ?age @@ -1009,16 +1009,16 @@ let test_sqlite_storage_backed_connections_filter_entity_rules_and_repeated_tran (transact_conn conn [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 25) + ; Add (Entity_id 1, "age", Int64 25L) ; Add (Entity_id 1, "aka", String "Terrible") ; Add (Entity_id 1, "aka", String "IV") ; Add (Entity_id 1, "password", String "") ; Add (Entity_id 1, "friend", Ref 2) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 37) + ; Add (Entity_id 2, "age", Int64 37L) ; Add (Entity_id 2, "password", String "") ; Add (Entity_id 3, "name", String "Nikolai") - ; Add (Entity_id 3, "age", Int 7) + ; Add (Entity_id 3, "age", Int64 7L) ]); let restored = match restore_conn storage with @@ -1092,7 +1092,7 @@ let test_sqlite_storage_backed_connections_filter_entity_rules_and_repeated_tran restored [ Add (Lookup_ref ("name", String "Ivan"), "tag", String "restored") ; Add (Entity_id 4, "name", String "Nina") - ; Add (Entity_id 4, "age", Int 42) + ; Add (Entity_id 4, "age", Int64 42L) ; Add (Lookup_ref ("name", String "Ivan"), "friend", Ref 4) ]); let restored_again = @@ -1127,13 +1127,13 @@ let test_sqlite_storage_backed_connections_index_query_and_transact_parity () = (transact_conn conn [ Add (Entity_id 1, "name", String "Petr") - ; Add (Entity_id 1, "age", Int 44) - ; Add (Entity_id 1, "path", List [ Int 1; Int 2 ]) + ; Add (Entity_id 1, "age", Int64 44L) + ; Add (Entity_id 1, "path", List [ Int64 1L; Int64 2L ]) ; Add (Entity_id 2, "name", String "Ivan") - ; Add (Entity_id 2, "age", Int 25) - ; Add (Entity_id 2, "path", List [ Int 1; Int 2; Int 3 ]) + ; Add (Entity_id 2, "age", Int64 25L) + ; Add (Entity_id 2, "path", List [ Int64 1L; Int64 2L; Int64 3L ]) ; Add (Entity_id 3, "name", String "Sergey") - ; Add (Entity_id 3, "age", Int 11) + ; Add (Entity_id 3, "age", Int64 11L) ]); let restored = match restore_conn storage with @@ -1143,35 +1143,35 @@ let test_sqlite_storage_backed_connections_index_query_and_transact_parity () = let restored_db = conn_db restored in assert_equal_triples "SQLite restored db preserves AEVT order" - [ 1, "age", Int 44 - ; 2, "age", Int 25 - ; 3, "age", Int 11 + [ 1, "age", Int64 44L + ; 2, "age", Int64 25L + ; 3, "age", Int64 11L ; 1, "name", String "Petr" ; 2, "name", String "Ivan" ; 3, "name", String "Sergey" - ; 1, "path", List [ Int 1; Int 2 ] - ; 2, "path", List [ Int 1; Int 2; Int 3 ] + ; 1, "path", List [ Int64 1L; Int64 2L ] + ; 2, "path", List [ Int64 1L; Int64 2L; Int64 3L ] ] (datoms restored_db Aevt ()); assert_equal_triples "SQLite restored db supports AVET seek across attrs" - [ 3, "age", Int 11 - ; 2, "age", Int 25 - ; 1, "age", Int 44 + [ 3, "age", Int64 11L + ; 2, "age", Int64 25L + ; 1, "age", Int64 44L ; 2, "name", String "Ivan" ; 1, "name", String "Petr" ; 3, "name", String "Sergey" - ; 1, "path", List [ Int 1; Int 2 ] - ; 2, "path", List [ Int 1; Int 2; Int 3 ] + ; 1, "path", List [ Int64 1L; Int64 2L ] + ; 2, "path", List [ Int64 1L; Int64 2L; Int64 3L ] ] - (seek_datoms restored_db Avet ~a:"age" ~v:(Int 10) ()); + (seek_datoms restored_db Avet ~a:"age" ~v:(Int64 10L) ()); assert_equal_triples "SQLite restored db supports AVET reverse seek" [ 1, "name", String "Petr" ; 2, "name", String "Ivan" - ; 1, "age", Int 44 - ; 2, "age", Int 25 - ; 3, "age", Int 11 + ; 1, "age", Int64 44L + ; 2, "age", Int64 25L + ; 3, "age", Int64 11L ] (rseek_datoms restored_db Avet ~a:"name" ~v:(String "Petr") ()); assert_equal_triples @@ -1186,8 +1186,8 @@ let test_sqlite_storage_backed_connections_index_query_and_transact_parity () = (transact_conn restored [ Add (Entity_id 4, "name", String "Nina") - ; Add (Entity_id 4, "age", Int 42) - ; Add (Entity_id 4, "path", List [ Int 2 ]) + ; Add (Entity_id 4, "age", Int64 42L) + ; Add (Entity_id 4, "path", List [ Int64 2L ]) ]); let restored_again = match restore storage with @@ -1200,8 +1200,8 @@ let test_sqlite_storage_backed_connections_index_query_and_transact_parity () = (q_string restored_again "[:find ?name :where [?e :age 42] [?e :name ?name]]"); assert_equal_triples "SQLite storage persists later indexed transacts for AVET" - [ 4, "age", Int 42; 1, "age", Int 44 ] - (index_range restored_again "age" ~start:(Int 42) ~stop:(Int 44) ())) + [ 4, "age", Int64 42L; 1, "age", Int64 44L ] + (index_range restored_again "age" ~start:(Int64 42L) ~stop:(Int64 44L) ())) let test_sqlite_storage_backed_composite_values_after_restore () = if not (sqlite3_available ()) then @@ -1212,7 +1212,7 @@ let test_sqlite_storage_backed_composite_values_after_restore () = let profile = Map [ Keyword "tags", Vector [ String "alpha"; String "beta" ] - ; Keyword "prefs", Map [ Keyword "theme", String "dark"; Keyword "pins", Vector [ Int 1; Int 2 ] ] + ; Keyword "prefs", Map [ Keyword "theme", String "dark"; Keyword "pins", Vector [ Int64 1L; Int64 2L ] ] ] in let conn = create_conn ~schema:[ "profile", indexed ] ~storage () in @@ -1231,7 +1231,7 @@ let test_sqlite_storage_backed_composite_values_after_restore () = "[:find ?e :where [?e :profile {:tags [\"alpha\" \"beta\"] :prefs {:pins [1 2] :theme \"dark\"}}]]"); assert_equal_query "SQLite restored db reads nested vector values out of map datom values" - [ [ Result_value (Vector [ Int 1; Int 2 ]) ] ] + [ [ Result_value (Vector [ Int64 1L; Int64 2L ]) ] ] (q_string restored_db "[:find ?pins :where [?e :profile ?profile] [(get ?profile :prefs) ?prefs] [(get ?prefs :pins) ?pins]]"); @@ -1253,11 +1253,11 @@ let test_sqlite_storage_backed_query_result_shapes_after_restore () = (transact_conn conn [ Add (Entity_id 1, "name", String "Petr") - ; Add (Entity_id 1, "age", Int 44) + ; Add (Entity_id 1, "age", Int64 44L) ; Add (Entity_id 2, "name", String "Ivan") - ; Add (Entity_id 2, "age", Int 25) + ; Add (Entity_id 2, "age", Int64 25L) ; Add (Entity_id 3, "name", String "Sergey") - ; Add (Entity_id 3, "age", Int 11) + ; Add (Entity_id 3, "age", Int64 11L) ]); let db = match restore_conn storage with @@ -1274,7 +1274,7 @@ let test_sqlite_storage_backed_query_result_shapes_after_restore () = then failwith "SQLite restored db should support collection find specs"; if q_return_string db "[:find (count ?name) . :where [_ :name ?name]]" - <> Query_scalar (Some (Result_value (Int 3))) + <> Query_scalar (Some (Result_value (Int64 3L))) then failwith "SQLite restored db should support scalar aggregate find specs"; if q_return_map_string @@ -1284,9 +1284,9 @@ let test_sqlite_storage_backed_query_result_shapes_after_restore () = :where [?e :name ?name] [?e :age ?age]]" <> Query_relation_maps - [ [ Keyword "a", Result_value (Int 25); Keyword "n", Result_value (String "Ivan") ] - ; [ Keyword "a", Result_value (Int 44); Keyword "n", Result_value (String "Petr") ] - ; [ Keyword "a", Result_value (Int 11); Keyword "n", Result_value (String "Sergey") ] + [ [ Keyword "a", Result_value (Int64 25L); Keyword "n", Result_value (String "Ivan") ] + ; [ Keyword "a", Result_value (Int64 44L); Keyword "n", Result_value (String "Petr") ] + ; [ Keyword "a", Result_value (Int64 11L); Keyword "n", Result_value (String "Sergey") ] ] then failwith "SQLite restored db should support relation return maps"; if @@ -1297,7 +1297,7 @@ let test_sqlite_storage_backed_query_result_shapes_after_restore () = :where [?e :name ?name] [(= ?name \"Ivan\")] [?e :age ?age]]" - <> Query_tuple_map (Some [ String "a", Result_value (Int 25); String "n", Result_value (String "Ivan") ]) + <> Query_tuple_map (Some [ String "a", Result_value (Int64 25L); String "n", Result_value (String "Ivan") ]) then failwith "SQLite restored db should support tuple return maps") let test_sqlite_storage_backed_lookup_ref_transacts_after_restore () = @@ -1330,7 +1330,7 @@ let test_sqlite_storage_backed_lookup_ref_transacts_after_restore () = ignore (transact_conn restored - [ Add (Lookup_ref ("name", String "Ivan"), "age", Int 35) + [ Add (Lookup_ref ("name", String "Ivan"), "age", Int64 35L) ; Add (Lookup_ref ("email", String "ivan@example.com"), "friend", Ref_to (Lookup_ref ("name", String "Petr"))) ; Add (Lookup_ref ("name", String "Ivan"), "friends", Ref_to (Lookup_ref ("name", String "Petr"))) ; Add (Lookup_ref ("name", String "Ivan"), "friends", Ref_to (Lookup_ref ("name", String "Oleg"))) @@ -1342,7 +1342,7 @@ let test_sqlite_storage_backed_lookup_ref_transacts_after_restore () = in assert_equal_query "SQLite storage persists lookup-ref add entity ids" - [ [ Result_value (Int 35) ] ] + [ [ Result_value (Int64 35L) ] ] (q_string (conn_db restored_again) "[:find ?age :where [[:name \"Ivan\"] :age ?age]]"); @@ -1370,7 +1370,7 @@ let test_sqlite_storage_backed_lookup_ref_transacts_after_restore () = , "friend" , Some (Ref_to (Lookup_ref ("name", String "Petr"))) , Ref_to (Lookup_ref ("name", String "Oleg")) ) - ; Retract (Lookup_ref ("name", String "Ivan"), "age", Some (Int 35)) + ; Retract (Lookup_ref ("name", String "Ivan"), "age", Some (Int64 35L)) ]); let final_db = match restore storage with @@ -1401,13 +1401,13 @@ let test_sqlite_storage_backed_not_or_queries_after_restore () = (transact_conn conn [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 10) + ; Add (Entity_id 1, "age", Int64 10L) ; Add (Entity_id 2, "name", String "Ivan") - ; Add (Entity_id 2, "age", Int 20) + ; Add (Entity_id 2, "age", Int64 20L) ; Add (Entity_id 3, "name", String "Oleg") - ; Add (Entity_id 3, "age", Int 10) + ; Add (Entity_id 3, "age", Int64 10L) ; Add (Entity_id 4, "name", String "Oleg") - ; Add (Entity_id 4, "age", Int 20) + ; Add (Entity_id 4, "age", Int64 20L) ]); let db = match restore storage with @@ -1420,8 +1420,8 @@ let test_sqlite_storage_backed_not_or_queries_after_restore () = (q_string db "[:find ?e :where [?e :name] (not [?e :name \"Ivan\"])]"); assert_equal_query "SQLite restored db supports not-join query clauses" - [ [ Result_entity 1; Result_value (Int 10) ] - ; [ Result_entity 2; Result_value (Int 20) ] + [ [ Result_entity 1; Result_value (Int64 10L) ] + ; [ Result_entity 2; Result_value (Int64 20L) ] ] (q_string db @@ -1445,7 +1445,7 @@ let test_sqlite_storage_backed_not_or_queries_after_restore () = :where (or-join [?e ?a] [?e :age ?a] [?e :name \"Oleg\"])]" - ~inputs:[ Arg_scalar (Result_value (Int 10)) ])) + ~inputs:[ Arg_scalar (Result_value (Int64 10L)) ])) let test_sqlite_storage_backed_transact_history_and_current_tx_parity () = if not (sqlite3_available ()) then @@ -1554,7 +1554,7 @@ let test_sqlite_storage_backed_transact_cljc_batch_after_restore () = { db_id = Some (Entity_id 1) ; attrs = [ "name", One_value (String "Ivan") - ; "age", One_value (Int 15) + ; "age", One_value (Int64 15L) ; "aka", Many_values [ String "Devil"; String "Tupen" ] ; "friend", One_value (Ref 2) ; "created-at", One_value TxRef @@ -1562,7 +1562,7 @@ let test_sqlite_storage_backed_transact_cljc_batch_after_restore () = } ; Entity { db_id = Some (Entity_id 2) - ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int 37) ] + ; attrs = [ "name", One_value (String "Petr"); "age", One_value (Int64 37L) ] } ; Add (CurrentTx, "tx/source", String "initial") ; Call (fun _ -> [ Entity { db_id = None; attrs = [ "name", One_value (String "Generated") ] } ]) @@ -1570,7 +1570,7 @@ let test_sqlite_storage_backed_transact_cljc_batch_after_restore () = ignore (transact_conn conn - [ CompareAndSet (Entity_id 1, "age", Some (Int 15), Int 16) + [ CompareAndSet (Entity_id 1, "age", Some (Int64 15L), Int64 16L) ; CompareAndSet (Entity_id 1, "label", None, String "fresh") ; Retract (Entity_id 1, "aka", Some (String "Devil")) ]); @@ -1581,7 +1581,7 @@ let test_sqlite_storage_backed_transact_cljc_batch_after_restore () = in assert_equal_query "SQLite restored db keeps cardinality-one replacement and CAS results" - [ [ Result_value (String "Ivan"); Result_value (Int 16); Result_value (String "fresh") ] ] + [ [ Result_value (String "Ivan"); Result_value (Int64 16L); Result_value (String "fresh") ] ] (q_string (conn_db restored) "[:find ?name ?age ?label @@ -1680,9 +1680,9 @@ let test_sqlite_storage_backed_pull_sources_and_relation_inputs_after_restore () (transact_conn score_conn [ Add (Entity_id 10, "email", String "ivan@example.com") - ; Add (Entity_id 10, "score", Int 20) + ; Add (Entity_id 10, "score", Int64 20L) ; Add (Entity_id 11, "email", String "petr@example.com") - ; Add (Entity_id 11, "score", Int 40) + ; Add (Entity_id 11, "score", Int64 40L) ]); let people = match restore people_storage with @@ -1696,8 +1696,8 @@ let test_sqlite_storage_backed_pull_sources_and_relation_inputs_after_restore () in assert_equal_query "SQLite restored named sources join across persisted dbs" - [ [ Result_value (String "Ivan"); Result_value (Int 20) ] - ; [ Result_value (String "Petr"); Result_value (Int 40) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 20L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 40L) ] ] (q_sources_string people @@ -1820,7 +1820,7 @@ let test_sqlite_storage_backed_aggregates_and_upserts_after_restore () = ; "email", One_value (String "ivan@example.com") ; "slug", One_value (String "ivan") ; "group", One_value (String "red") - ; "score", One_value (Int 10) + ; "score", One_value (Int64 10L) ] } ; Entity @@ -1830,7 +1830,7 @@ let test_sqlite_storage_backed_aggregates_and_upserts_after_restore () = ; "email", One_value (String "petr@example.com") ; "slug", One_value (String "petr") ; "group", One_value (String "red") - ; "score", One_value (Int 20) + ; "score", One_value (Int64 20L) ] } ; Entity @@ -1840,7 +1840,7 @@ let test_sqlite_storage_backed_aggregates_and_upserts_after_restore () = ; "email", One_value (String "oleg@example.com") ; "slug", One_value (String "oleg") ; "group", One_value (String "blue") - ; "score", One_value (Int 5) + ; "score", One_value (Int64 5L) ] } ]); @@ -1851,8 +1851,8 @@ let test_sqlite_storage_backed_aggregates_and_upserts_after_restore () = in assert_equal_query "SQLite restored db supports grouped aggregate queries" - [ [ Result_value (String "blue"); Result_value (Int 1); Result_value (Int 5) ] - ; [ Result_value (String "red"); Result_value (Int 2); Result_value (Int 30) ] + [ [ Result_value (String "blue"); Result_value (Int64 1L); Result_value (Int64 5L) ] + ; [ Result_value (String "red"); Result_value (Int64 2L); Result_value (Int64 30L) ] ] (q_string (conn_db restored) @@ -1867,11 +1867,11 @@ let test_sqlite_storage_backed_aggregates_and_upserts_after_restore () = ; attrs = [ "name", One_value (String "Ivan") ; "email", One_value (String "ivan+updated@example.com") - ; "score", One_value (Int 15) + ; "score", One_value (Int64 15L) ] } ; Add (Temp_id "petr", "name", String "Petr") - ; Add (Temp_id "petr", "score", Int 25) + ; Add (Temp_id "petr", "score", Int64 25L) ; Add (Temp_id "oleg", "name", String "Oleg") ; Add (Temp_id "oleg", "email", String "oleg@example.com") ; Add (Temp_id "oleg", "group", String "green") @@ -1887,19 +1887,19 @@ let test_sqlite_storage_backed_aggregates_and_upserts_after_restore () = ; Result_value (String "Ivan") ; Result_value (String "ivan+updated@example.com") ; Result_value (String "red") - ; Result_value (Int 15) + ; Result_value (Int64 15L) ] ; [ Result_entity 2 ; Result_value (String "Petr") ; Result_value (String "petr@example.com") ; Result_value (String "red") - ; Result_value (Int 25) + ; Result_value (Int64 25L) ] ; [ Result_entity 3 ; Result_value (String "Oleg") ; Result_value (String "oleg@example.com") ; Result_value (String "green") - ; Result_value (Int 5) + ; Result_value (Int64 5L) ] ] (q_string @@ -2023,15 +2023,15 @@ let test_sqlite_storage_backed_parsed_transact_and_query_pull_parity () = [?tx :kind ?kind]]"); assert_equal_query "SQLite restored db supports relation input bindings after parsed transact" - [ [ Result_value (String "Ivan"); Result_value (Int 25) ] - ; [ Result_value (String "Petr"); Result_value (Int 44) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 25L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 44L) ] ] (q_string ~inputs: [ Arg_relation - [ [ Result_value (String "Ivan"); Result_value (Int 18) ] - ; [ Result_value (String "Petr"); Result_value (Int 18) ] - ; [ Result_value (String "Oleg"); Result_value (Int 18) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 18L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 18L) ] + ; [ Result_value (String "Oleg"); Result_value (Int64 18L) ] ] ] people @@ -2071,21 +2071,21 @@ let test_sqlite_storage_backed_parsed_transact_and_query_pull_parity () = assert_equal_query "SQLite restored db supports pull with lookup-ref collection inputs" [ [ Result_value (Ref_to (Lookup_ref ("name", String "Ivan"))) - ; Result_value (Int 25) + ; Result_value (Int64 25L) ; Result_pull { pulled_id = 1 ; pulled_attrs = - [ Keyword "db/id", Pulled_scalar (Int 1) + [ Keyword "db/id", Pulled_scalar (Int64 1L) ; Keyword "name", Pulled_scalar (String "Ivan") ] } ] ; [ Result_value (Ref_to (Lookup_ref ("name", String "Petr"))) - ; Result_value (Int 44) + ; Result_value (Int64 44L) ; Result_pull { pulled_id = 2 ; pulled_attrs = - [ Keyword "db/id", Pulled_scalar (Int 2) + [ Keyword "db/id", Pulled_scalar (Int64 2L) ; Keyword "name", Pulled_scalar (String "Petr") ] } @@ -2109,13 +2109,13 @@ let test_sqlite_storage_backed_parsed_transact_and_query_pull_parity () = [ [ Result_value (String "Ivan") ; Result_pull { pulled_id = 10 - ; pulled_attrs = [ Keyword "score", Pulled_scalar (Int 20) ] + ; pulled_attrs = [ Keyword "score", Pulled_scalar (Int64 20L) ] } ] ; [ Result_value (String "Petr") ; Result_pull { pulled_id = 11 - ; pulled_attrs = [ Keyword "score", Pulled_scalar (Int 40) ] + ; pulled_attrs = [ Keyword "score", Pulled_scalar (Int64 40L) ] } ] ] @@ -2146,21 +2146,21 @@ let test_sqlite_storage_backed_query_input_maps_after_restore () = (transact_conn conn [ Add (Entity_id 1, "name", String "Ivan") - ; Add (Entity_id 1, "age", Int 25) - ; Add (Entity_id 1, "score", Int 4) + ; Add (Entity_id 1, "age", Int64 25L) + ; Add (Entity_id 1, "score", Int64 4L) ; Add (Entity_id 2, "name", String "Petr") - ; Add (Entity_id 2, "age", Int 44) - ; Add (Entity_id 2, "score", Int 7) + ; Add (Entity_id 2, "age", Int64 44L) + ; Add (Entity_id 2, "score", Int64 7L) ; Add (Entity_id 3, "name", String "Oleg") - ; Add (Entity_id 3, "age", Int 11) - ; Add (Entity_id 3, "score", Int 2) + ; Add (Entity_id 3, "age", Int64 11L) + ; Add (Entity_id 3, "score", Int64 2L) ]); let restored = match restore_conn storage with | Some conn -> conn | None -> failwith "SQLite storage should restore conn for query input map test" in - ignore (transact_conn restored [ Add (Lookup_ref ("name", String "Oleg"), "age", Int 18) ]); + ignore (transact_conn restored [ Add (Lookup_ref ("name", String "Oleg"), "age", Int64 18L) ]); let db = match restore storage with | Some db -> db @@ -2168,18 +2168,18 @@ let test_sqlite_storage_backed_query_input_maps_after_restore () = in assert_equal_query "SQLite restored db joins plain map relation inputs after transact" - [ [ Result_value (String "Ivan"); Result_value (Int 25) ] - ; [ Result_value (String "Oleg"); Result_value (Int 18) ] - ; [ Result_value (String "Petr"); Result_value (Int 44) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 25L) ] + ; [ Result_value (String "Oleg"); Result_value (Int64 18L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 44L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ String "Ivan", Int 18 - ; String "Oleg", Int 18 - ; String "Petr", Int 18 + [ String "Ivan", Int64 18L + ; String "Oleg", Int64 18L + ; String "Petr", Int64 18L ])) ] db @@ -2196,29 +2196,29 @@ let test_sqlite_storage_backed_query_input_maps_after_restore () = let min_value, max_value = List.fold_left (fun (min_value, max_value) -> function - | Int value -> min min_value value, max max_value value + | Int64 value -> Int64.min min_value value, Int64.max max_value value | _ -> min_value, max_value) (match first with - | Int value -> value, value - | _ -> 0, 0) + | Int64 value -> value, value + | _ -> 0L, 0L) rest in - Some [ Result_value (Int min_value); Result_value (Int max_value) ]) + Some [ Result_value (Int64 min_value); Result_value (Int64 max_value) ]) | _ -> None in assert_equal_query "SQLite restored db joins map relation rows through dynamic tuple outputs" - [ [ Result_value (String "Ivan"); Result_value (Int 1); Result_value (Int 4) ] - ; [ Result_value (String "Petr"); Result_value (Int 5); Result_value (Int 7) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 1L); Result_value (Int64 4L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 5L); Result_value (Int64 7L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ String "Ivan", List [ Int 1; Int 4 ] - ; String "Petr", List [ Int 5; Int 7 ] - ; String "Oleg", List [ Int 2; Int 2 ] + [ String "Ivan", List [ Int64 1L; Int64 4L ] + ; String "Petr", List [ Int64 5L; Int64 7L ] + ; String "Oleg", List [ Int64 2L; Int64 2L ] ])) ; Arg_function minmax ] @@ -2231,28 +2231,28 @@ let test_sqlite_storage_backed_query_input_maps_after_restore () = [(= ?score ?max)] [(> ?max ?min)]]"); let range_values = function - | [ Result_value (Int min_value); Result_value (Int max_value) ] -> + | [ Result_value (Int64 min_value); Result_value (Int64 max_value) ] -> let rec collect value acc = if value >= max_value then List.rev acc - else collect (value + 1) (Int value :: acc) + else collect (Int64.add value 1L) (Int64 value :: acc) in Some [ Result_value (List (collect min_value [])) ] | _ -> None in assert_equal_query "SQLite restored db joins nested map relation rows through dynamic collection outputs" - [ [ Result_value (String "Ivan"); Result_value (Int 2) ] - ; [ Result_value (String "Ivan"); Result_value (Int 4) ] - ; [ Result_value (String "Petr"); Result_value (Int 6) ] + [ [ Result_value (String "Ivan"); Result_value (Int64 2L) ] + ; [ Result_value (String "Ivan"); Result_value (Int64 4L) ] + ; [ Result_value (String "Petr"); Result_value (Int64 6L) ] ] (q_string ~inputs: [ Arg_scalar (Result_value (Map - [ String "Ivan", List [ Int 1; Int 5 ] - ; String "Petr", List [ Int 6; Int 8 ] - ; String "Oleg", List [ Int 3; Int 4 ] + [ String "Ivan", List [ Int64 1L; Int64 5L ] + ; String "Petr", List [ Int64 6L; Int64 8L ] + ; String "Oleg", List [ Int64 3L; Int64 4L ] ])) ; Arg_function range_values ] @@ -2266,9 +2266,9 @@ let test_sqlite_storage_backed_query_input_maps_after_restore () = [(< ?candidate ?age)]]"); assert_equal_query "SQLite restored db accepts input-only queries with no db source" - [ [ Result_value (Int 10); Result_value (Int 20) ] ] + [ [ Result_value (Int64 10L); Result_value (Int64 20L) ] ] (q_string - ~inputs:[ Arg_scalar (Result_value (Int 10)); Arg_scalar (Result_value (Int 20)) ] + ~inputs:[ Arg_scalar (Result_value (Int64 10L)); Arg_scalar (Result_value (Int64 20L)) ] db "[:find ?a ?b :in ?a ?b]")) @@ -2290,13 +2290,13 @@ let test_logseq_sqlite_import_preserves_clojure_collection_values () = let datoms = Sqlite_storage.datoms_of_logseq_graph ~read_only:true db_path in assert_equal_triples "Logseq SQLite import preserves vector/list/map value shapes" - [ 101, "item/vector", Vector [ Int 1; Int 2 ] - ; 102, "item/list", List [ Int 1; Int 2 ] + [ 101, "item/vector", Vector [ Int64 1L; Int64 2L ] + ; 102, "item/list", List [ Int64 1L; Int64 2L ] ; ( 103 , "item/profile" , Map [ Keyword "tags", Vector [ String "alpha"; String "beta" ] - ; Keyword "prefs", Map [ Keyword "pins", Vector [ Int 1; Int 2 ] ] + ; Keyword "prefs", Map [ Keyword "pins", Vector [ Int64 1L; Int64 2L ] ] ] ) ] datoms; @@ -2307,7 +2307,7 @@ let test_logseq_sqlite_import_preserves_clojure_collection_values () = (q_string db "[:find ?e :where [?e :item/vector [1 2]]]"); assert_equal_query "Logseq SQLite imported nested map vectors query structurally" - [ [ Result_value (Vector [ Int 1; Int 2 ]) ] ] + [ [ Result_value (Vector [ Int64 1L; Int64 2L ]) ] ] (q_string db "[:find ?pins :where [?e :item/profile ?profile] [(get ?profile :prefs) ?prefs] [(get ?prefs :pins) ?pins]]")) @@ -2330,8 +2330,8 @@ let test_logseq_sqlite_datom_cache_ignores_uuid_values () = let datoms = Sqlite_storage.datoms_of_logseq_graph ~read_only:true db_path in assert_equal_triples "Logseq datom cache codes should not be shifted by UUID values" - [ 97, "block/created-at", Int 1778143747442 ] - (List.filter (fun datom -> datom.e = 97 && datom.v = Int 1778143747442) datoms)) + [ 97, "block/created-at", Int64 1778143747442L ] + (List.filter (fun datom -> datom.e = 97 && datom.v = Int64 1778143747442L) datoms)) let test_logseq_sqlite_datom_cache_ignores_transit_tag_values () = if not (sqlite3_available ()) then @@ -2350,7 +2350,7 @@ let test_logseq_sqlite_datom_cache_ignores_transit_tag_values () = ^ ", '[]');")); assert_equal_triples "Logseq datom cache codes should not be shifted by Transit tags" - [ 2, "block/created-at", Int 1000; 3, "block/created-at", Int 2000 ] + [ 2, "block/created-at", Int64 1000L; 3, "block/created-at", Int64 2000L ] (Sqlite_storage.datoms_of_logseq_graph ~read_only:true db_path |> List.filter (fun datom -> datom.a = "block/created-at"))) @@ -2377,7 +2377,7 @@ let test_logseq_sqlite_datom_cache_spans_ordered_rows () = ^ ", '[]');")); assert_equal_triples "Logseq datom cache codes should carry across SQLite rows in addr order" - [ 1, "block/created-at", Int 1000; 2, "block/created-at", Int 2000 ] + [ 1, "block/created-at", Int64 1000L; 2, "block/created-at", Int64 2000L ] (Sqlite_storage.datoms_of_logseq_graph ~read_only:true db_path)) let test_logseq_sqlite_query_loads_matching_nodes_without_full_materialization () = @@ -2406,8 +2406,8 @@ let test_logseq_sqlite_query_loads_matching_nodes_without_full_materialization ( ^ ", '[]');"); assert_equal_query "direct Logseq SQLite query should load only matching graph nodes" - [ [ Result_value (Int 1000); Result_value (String "Alpha") ] - ; [ Result_value (Int 2000); Result_value (String "Beta") ] + [ [ Result_value (Int64 1000L); Result_value (String "Alpha") ] + ; [ Result_value (Int64 2000L); Result_value (String "Beta") ] ] (match Sqlite_storage.query_logseq_graph @@ -2464,9 +2464,9 @@ let test_logseq_sqlite_query_treats_timestamp_attrs_as_scalars_when_schema_marks assert_equal_query "direct Logseq SQLite query should keep timestamp attrs as scalar values" [ [ Result_value (String "Lambda") - ; Result_value (Int 1743432598614) - ; Result_value (Int 1743432616414) - ; Result_value (Int 1747740706964) + ; Result_value (Int64 1743432598614L) + ; Result_value (Int64 1743432616414L) + ; Result_value (Int64 1747740706964L) ] ] (match @@ -2532,7 +2532,7 @@ let logseq_root_content schema = let logseq_json_of_value = function | String value -> json_quote value - | Int value -> string_of_int value + | Int64 value -> Int64.to_string value | Bool value -> if value then "true" else "false" | Keyword value -> json_quote ("~:" ^ value) | Ref entity_id -> string_of_int entity_id @@ -2611,8 +2611,8 @@ let test_logseq_sqlite_generated_graph_queries_transacted_properties_and_blocks ; Add (Entity_id 400, "block/title", String "Ship generated sqlite") ; Add (Entity_id 400, "block/page", Ref 300) ; Add (Entity_id 400, "block/order", String "a0") - ; Add (Entity_id 400, "block/created-at", Int 1781829000000) - ; Add (Entity_id 400, "block/updated-at", Int 1781829297990) + ; Add (Entity_id 400, "block/created-at", Int64 1781829000000L) + ; Add (Entity_id 400, "block/updated-at", Int64 1781829297990L) ; Add (Entity_id 400, "user/priority", String "high") ] in @@ -2645,7 +2645,7 @@ let test_logseq_sqlite_generated_graph_queries_transacted_properties_and_blocks "generated Logseq sqlite should query transacted blocks with custom properties" [ [ Result_value (String "Ship generated sqlite") ; Result_value (String "high") - ; Result_value (Int 1781829297990) + ; Result_value (Int64 1781829297990L) ] ] (match @@ -2848,7 +2848,7 @@ let datom_has_unsupported_entity_id schema datom = || match List.assoc_opt datom.a schema, datom.v with | _, Ref entity_id -> unsupported_entity_id entity_id - | Some { value_type = Some RefType; _ }, Int _ + | Some { value_type = Some RefType; _ }, Int64 _ | _ -> false let find_unsupported_entity_id_datoms schema datoms = diff --git a/test/test_storage.ml b/test/test_storage.ml index 4348c52..35e093b 100644 --- a/test/test_storage.ml +++ b/test/test_storage.ml @@ -355,11 +355,11 @@ let test_storage__test_conn () = let test_storage__test_db_with_tail () = let db = empty_db ~schema:[ "block/updated-at", indexed; "block/uuid", unique_identity ] () - |> db_with [ Add (Entity_id 1, "block/updated-at", Int 2); Add (Entity_id 1, "block/uuid", String "u1") ] + |> db_with [ Add (Entity_id 1, "block/updated-at", Int64 2L); Add (Entity_id 1, "block/uuid", String "u1") ] in let tail = - [ [ datom ~tx:(tx0 + 3) ~e:1 ~a:"block/updated-at" ~v:(Int 1772979060646) () ] - ; [ datom ~tx:(tx0 + 4) ~e:1 ~a:"block/updated-at" ~v:(Int 1772979061145) () ] + [ [ datom ~tx:(tx0 + 3) ~e:1 ~a:"block/updated-at" ~v:(Int64 1772979060646L) () ] + ; [ datom ~tx:(tx0 + 4) ~e:1 ~a:"block/updated-at" ~v:(Int64 1772979061145L) () ] ; [ datom ~tx:(tx0 + 5) ~e:2 ~a:"block/uuid" ~v:(String "u1") () ; datom ~tx:(tx0 + 5) ~e:2 ~a:"block/title" ~v:(String "Rejected") () ] @@ -369,7 +369,7 @@ let test_storage__test_db_with_tail () = let restored = db_with_tail db tail in assert_equal_triples "db_with_tail retracts stale cardinality-one values" - [ 1, "block/updated-at", Int 1772979061145 ] + [ 1, "block/updated-at", Int64 1772979061145L ] (datoms restored Avet ~a:"block/updated-at" ()); assert_equal_triples "db_with_tail drops rejected unique-conflict tail groups" diff --git a/test/test_tuples.ml b/test/test_tuples.ml index 1bc5908..ddd6781 100644 --- a/test/test_tuples.ml +++ b/test/test_tuples.ml @@ -174,7 +174,7 @@ let test_tuples__test_ignore_correct () = "matching direct tuple write is ignored" (conn_db conn) (Entity_id 1) - [ Keyword "a", scalar (String "a"); Keyword "a+b", scalar (tuple_value [ String "a"; String "B" ]); Keyword "b", scalar (String "B"); Keyword "db/id", scalar (Int 1) ] + [ Keyword "a", scalar (String "a"); Keyword "a+b", scalar (tuple_value [ String "a"; String "B" ]); Keyword "b", scalar (String "B"); Keyword "db/id", scalar (Int64 1L) ] let test_tuples__test_unique () = let conn = create_conn ~schema:[ "a+b", tuple_unique_identity [ "a"; "b" ] ] () in @@ -195,13 +195,13 @@ let test_tuples__test_unique () = "multiple tuple updates are atomic" (conn_db conn) (Entity_id 1) - [ Keyword "a", scalar (String "A"); Keyword "a+b", scalar (tuple_value [ String "A"; String "B" ]); Keyword "b", scalar (String "B"); Keyword "db/id", scalar (Int 1) ]; + [ Keyword "a", scalar (String "A"); Keyword "a+b", scalar (tuple_value [ String "A"; String "B" ]); Keyword "b", scalar (String "B"); Keyword "db/id", scalar (Int64 1L) ]; ignore (transact_bang conn [ Entity { db_id = Some (Entity_id 4); attrs = [ "a", One_value (String "a"); "b", One_value (String "b") ] } ]); expect_pull_attrs "insert with two tuple components is atomic" (conn_db conn) (Entity_id 4) - [ Keyword "a", scalar (String "a"); Keyword "a+b", scalar (tuple_value [ String "a"; String "b" ]); Keyword "b", scalar (String "b"); Keyword "db/id", scalar (Int 4) ] + [ Keyword "a", scalar (String "a"); Keyword "a+b", scalar (tuple_value [ String "a"; String "b" ]); Keyword "b", scalar (String "b"); Keyword "db/id", scalar (Int64 4L) ] let test_tuples__test_upsert () = let conn = create_conn ~schema:[ "a+b", tuple_unique_identity [ "a"; "b" ]; "c", unique_identity ] () in @@ -231,7 +231,7 @@ let test_tuples__test_upsert () = "change tuple source during upsert" (conn_db conn) (Entity_id 1) - [ Keyword "a", scalar (String "A"); Keyword "a+b", scalar (tuple_value [ String "A"; String "b" ]); Keyword "b", scalar (String "b"); Keyword "c", scalar (String "C"); Keyword "d", scalar (String "D"); Keyword "db/id", scalar (Int 1) ] + [ Keyword "a", scalar (String "A"); Keyword "a+b", scalar (tuple_value [ String "A"; String "b" ]); Keyword "b", scalar (String "b"); Keyword "c", scalar (String "C"); Keyword "d", scalar (String "D"); Keyword "db/id", scalar (Int64 1L) ] let test_tuples__test_upsert_by_tuple_components () = let db = @@ -279,7 +279,7 @@ let test_tuples__test_lookup_refs () = "pull by tuple lookup ref" (conn_db conn) (Lookup_ref ("a+b", tuple_value [ String "a"; String "b" ])) - [ Keyword "a", scalar (String "a"); Keyword "a+b", scalar (tuple_value [ String "a"; String "b" ]); Keyword "b", scalar (String "b"); Keyword "c", scalar (String "c"); Keyword "db/id", scalar (Int 2) ] + [ Keyword "a", scalar (String "a"); Keyword "a+b", scalar (tuple_value [ String "a"; String "b" ]); Keyword "b", scalar (String "b"); Keyword "c", scalar (String "c"); Keyword "db/id", scalar (Int64 2L) ] let test_tuples__lookup_refs_in_tuple () = let db = @@ -291,18 +291,18 @@ let test_tuples__lookup_refs_in_tuple () = ; Entity { db_id = Some (Temp_id "yuri"); attrs = [ "name", One_value (String "Yuri"); "ref", One_value (Ref_to (Temp_id "oleg")) ] } ] in - let by_id = db_with [ Entity { db_id = None; attrs = [ "ref+name", One_value (tuple_value [ Ref 1; String "Petr" ]); "age", One_value (Int 32) ] } ] db in - expect_pull_attrs ~pattern:[ Pull_attr "age" ] "tuple lookup with id ref" by_id (Entity_id 3) [ Keyword "age", scalar (Int 32) ]; + let by_id = db_with [ Entity { db_id = None; attrs = [ "ref+name", One_value (tuple_value [ Ref 1; String "Petr" ]); "age", One_value (Int64 32L) ] } ] db in + expect_pull_attrs ~pattern:[ Pull_attr "age" ] "tuple lookup with id ref" by_id (Entity_id 3) [ Keyword "age", scalar (Int64 32L) ]; let by_lookup = db_with [ Entity { db_id = None - ; attrs = [ "ref+name", One_value (Tuple [ Some (Vector [ Keyword "name"; String "Ivan" ]); Some (String "Petr") ]); "age", One_value (Int 32) ] + ; attrs = [ "ref+name", One_value (Tuple [ Some (Vector [ Keyword "name"; String "Ivan" ]); Some (String "Petr") ]); "age", One_value (Int64 32L) ] } ] db in - expect_pull_attrs ~pattern:[ Pull_attr "age" ] "tuple lookup with nested lookup ref" by_lookup (Entity_id 3) [ Keyword "age", scalar (Int 32) ]; + expect_pull_attrs ~pattern:[ Pull_attr "age" ] "tuple lookup with nested lookup ref" by_lookup (Entity_id 3) [ Keyword "age", scalar (Int64 32L) ]; if entid db "ref+name" (tuple_value [ Ref 1; String "Petr" ]) <> Some 3 then failf "tuple entid by id ref"; if entid db "ref+name" (Vector [ Vector [ Keyword "name"; String "Ivan" ]; String "Petr" ]) <> Some 3 then failf "tuple entid by nested lookup ref" diff --git a/test/test_upsert.ml b/test/test_upsert.ml index 1379572..82a5b74 100644 --- a/test/test_upsert.ml +++ b/test/test_upsert.ml @@ -96,42 +96,42 @@ let assert_entity label expected db entity_id = let test_upsert__test_upsert () = let db = base_db () in - let tx = transact db [ entity [ one "name" (String "Ivan"); one "age" (Int 35) ] ] in + let tx = transact db [ entity [ one "name" (String "Ivan"); one "age" (Int64 35L) ] ] in assert_entity "upsert, no tempid" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "upsert, no tempid has no user tempids" [] tx.tempids; let tx = - transact db [ entity [ one "name" (String "Ivan"); one "email" (String "@1"); one "age" (Int 35) ] ] + transact db [ entity [ one "name" (String "Ivan"); one "email" (String "@1"); one "age" (Int64 35L) ] ] in assert_entity "upsert by 2 attrs, no tempid" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "upsert by 2 attrs, no tempid has no user tempids" [] tx.tempids; let tx = - transact db [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int 35) ] ] + transact db [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int64 35L) ] ] in assert_entity "upsert with tempid" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "upsert with tempid resolves existing entity" [ "-1", 1 ] tx.tempids; let tx = transact db - [ entity ~db_id:(Temp_id "1") [ one "name" (String "Ivan"); one "age" (Int 35) ] + [ entity ~db_id:(Temp_id "1") [ one "name" (String "Ivan"); one "age" (Int64 35L) ] ; Add (Temp_id "2", "name", String "Oleg") ; Add (Temp_id "2", "email", String "@2") ] in assert_entity "upsert with string tempid updates first entity" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_entity @@ -143,41 +143,41 @@ let test_upsert__test_upsert () = let tx = transact db - [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "email" (String "@1"); one "age" (Int 35) ] ] + [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "email" (String "@1"); one "age" (Int64 35L) ] ] in assert_entity "upsert by 2 attrs with tempid" - [ 1, "age", Int 35; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "upsert by 2 attrs with tempid resolves existing entity" [ "-1", 1 ] tx.tempids; let tx = transact db - [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int 35) ] - ; entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int 36) ] + [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int64 35L) ] + ; entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int64 36L) ] ] in assert_entity "upsert to two entities, resolve to same tempid" - [ 1, "age", Int 36; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 36L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "same tempid remains resolved to one entity" [ "-1", 1 ] tx.tempids; let tx = transact db - [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int 35) ] - ; entity ~db_id:(Temp_id "-2") [ one "name" (String "Ivan"); one "age" (Int 36) ] + [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int64 35L) ] + ; entity ~db_id:(Temp_id "-2") [ one "name" (String "Ivan"); one "age" (Int64 36L) ] ] in assert_entity "upsert to two entities, two tempids" - [ 1, "age", Int 36; 1, "email", String "@1"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 36L; 1, "email", String "@1"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "two tempids resolve to the same existing entity" [ "-1", 1; "-2", 1 ] tx.tempids; - ignore (transact db [ entity ~db_id:(Entity_id 1) [ one "name" (String "Ivan"); one "age" (Int 35) ] ]); + ignore (transact db [ entity ~db_id:(Entity_id 1) [ one "name" (String "Ivan"); one "age" (Int64 35L) ] ]); ignore (transact db @@ -185,25 +185,25 @@ let test_upsert__test_upsert () = ~db_id:(Lookup_ref ("name", String "Ivan")) [ one "name" (String "Ivan") ; one "email" (String "@1") - ; one "age" (Int 35) + ; one "age" (Int64 35L) ] ]); assert_raises_invalid_arg_message "upsert conflicts with existing id" "Conflicting upsert: [:name \"Ivan\"] resolves to 1, but entity already has :db/id 2" (fun () -> - ignore (transact db [ entity ~db_id:(Entity_id 2) [ one "name" (String "Ivan"); one "age" (Int 36) ] ])); + ignore (transact db [ entity ~db_id:(Entity_id 2) [ one "name" (String "Ivan"); one "age" (Int64 36L) ] ])); assert_raises_invalid_arg_message "upsert conflicts with non-existing id" "Conflicting upsert: [:name \"Ivan\"] resolves to 1, but entity already has :db/id 5" (fun () -> - ignore (transact db [ entity ~db_id:(Entity_id 5) [ one "name" (String "Ivan"); one "age" (Int 36) ] ])); + ignore (transact db [ entity ~db_id:(Entity_id 5) [ one "name" (String "Ivan"); one "age" (Int64 36L) ] ])); let tx = - transact db [ entity [ one "name" (String "Ivan"); one "email" (String "@5"); one "age" (Int 35) ] ] + transact db [ entity [ one "name" (String "Ivan"); one "email" (String "@5"); one "age" (Int64 35L) ] ] in assert_entity "upsert by non-existing value resolves as update" - [ 1, "age", Int 35; 1, "email", String "@5"; 1, "name", String "Ivan" ] + [ 1, "age", Int64 35L; 1, "email", String "@5"; 1, "name", String "Ivan" ] tx.db_after 1; assert_equal_tempids "upsert by non-existing value has no user tempids" [] tx.tempids; @@ -211,24 +211,24 @@ let test_upsert__test_upsert () = "upsert by 2 conflicting fields" "Conflicting upserts: [:name \"Ivan\"] resolves to 1, but [:email \"@2\"] resolves to 2" (fun () -> - ignore (transact db [ entity [ one "name" (String "Ivan"); one "email" (String "@2"); one "age" (Int 35) ] ])); + ignore (transact db [ entity [ one "name" (String "Ivan"); one "email" (String "@2"); one "age" (Int64 35L) ] ])); let tx = - transact db [ entity [ one "name" (String "Igor"); one "age" (Int 35) ]; entity [ one "name" (String "Igor"); one "age" (Int 36) ] ] + transact db [ entity [ one "name" (String "Igor"); one "age" (Int64 35L) ]; entity [ one "name" (String "Igor"); one "age" (Int64 36L) ] ] in - assert_entity "upsert over intermediate db" [ 5, "age", Int 36; 5, "name", String "Igor" ] tx.db_after 5; + assert_entity "upsert over intermediate db" [ 5, "age", Int64 36L; 5, "name", String "Igor" ] tx.db_after 5; let tx = transact db - [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Igor"); one "age" (Int 35) ] - ; entity ~db_id:(Temp_id "-2") [ one "name" (String "Igor"); one "age" (Int 36) ] + [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Igor"); one "age" (Int64 35L) ] + ; entity ~db_id:(Temp_id "-2") [ one "name" (String "Igor"); one "age" (Int64 36L) ] ] in - assert_entity "upsert over intermediate db, different tempids" [ 5, "age", Int 36; 5, "name", String "Igor" ] tx.db_after 5; + assert_entity "upsert over intermediate db, different tempids" [ 5, "age", Int64 36L; 5, "name", String "Igor" ] tx.db_after 5; assert_equal_tempids "intermediate upsert tempids resolve together" [ "-1", 5; "-2", 5 ] tx.tempids; assert_raises_invalid_arg "upsert and current-tx conflict" (fun () -> - ignore (transact db [ entity ~db_id:CurrentTx [ one "name" (String "Ivan"); one "age" (Int 35) ] ])); + ignore (transact db [ entity ~db_id:CurrentTx [ one "name" (String "Ivan"); one "age" (Int64 35L) ] ])); let tx = transact db @@ -255,10 +255,10 @@ let test_upsert__test_upsert () = ignore (transact tx.db_after [ entity [ many "slugs" [ String "ivan1"; String "petr1" ] ] ])); [ 3, 2, 36; 4, 3, 37; 1, 4, 38 ] |> List.iter (fun (ref_e, target_e, age) -> - let tx = transact db [ entity [ one "ref" (Ref ref_e); one "age" (Int age) ] ] in + let tx = transact db [ entity [ one "ref" (Ref ref_e); one "age" (Int64 (Int64.of_int age)) ] ] in assert_entity "upsert by ref" - [ target_e, "age", Int age + [ target_e, "age", Int64 (Int64.of_int age) ; target_e, "email", String (if target_e = 2 then "@2" else if target_e = 3 then "@3" else "@4") ; target_e, "name", String (if target_e = 2 then "Petr" else if target_e = 3 then "Dima" else "Olga") ; target_e, "ref", Ref ref_e @@ -268,11 +268,11 @@ let test_upsert__test_upsert () = [ "Dima", 2, 3, 36; "Olga", 3, 4, 37; "Ivan", 4, 1, 38 ] |> List.iter (fun (lookup_name, target_e, ref_e, age) -> let tx = - transact db [ entity [ one "ref" (Ref_to (Lookup_ref ("name", String lookup_name))); one "age" (Int age) ] ] + transact db [ entity [ one "ref" (Ref_to (Lookup_ref ("name", String lookup_name))); one "age" (Int64 (Int64.of_int age)) ] ] in assert_entity "upsert by lookup ref" - [ target_e, "age", Int age + [ target_e, "age", Int64 (Int64.of_int age) ; target_e, "email", String (if target_e = 2 then "@2" else if target_e = 3 then "@3" else "@4") ; target_e, "name", String (if target_e = 2 then "Petr" else if target_e = 3 then "Dima" else "Olga") ; target_e, "ref", Ref ref_e @@ -297,13 +297,13 @@ let test_upsert__test_redefining_ids () = let tx = transact db - [ entity ~db_id:(Temp_id "-1") [ one "age" (Int 35) ] - ; entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int 36) ] + [ entity ~db_id:(Temp_id "-1") [ one "age" (Int64 35L) ] + ; entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int64 36L) ] ] in assert_equal_triples "redefining ids keeps the upsert target" - [ 1, "age", Int 36; 1, "name", String "Ivan" ] + [ 1, "age", Int64 36L; 1, "name", String "Ivan" ] (datoms tx.db_after Eavt ()); assert_equal_tempids "redefined tempid resolves to existing entity" [ "-1", 1 ] tx.tempids; let db = @@ -320,15 +320,15 @@ let test_upsert__test_redefining_ids () = ignore (transact db - [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int 35) ] - ; entity ~db_id:(Temp_id "-1") [ one "name" (String "Oleg"); one "age" (Int 36) ] + [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan"); one "age" (Int64 35L) ] + ; entity ~db_id:(Temp_id "-1") [ one "name" (String "Oleg"); one "age" (Int64 36L) ] ])) let test_upsert__test_retries_order () = let first = empty_db ~schema:[ "name", unique_identity ] () |> db_with - [ Add (Temp_id "-1", "age", Int 42) + [ Add (Temp_id "-1", "age", Int64 42L) ; Add (Temp_id "-2", "likes", String "Pizza") ; Add (Temp_id "-1", "name", String "Bob") ; Add (Temp_id "-2", "name", String "Bob") @@ -336,12 +336,12 @@ let test_upsert__test_retries_order () = in assert_equal_triples "retry order merges later tempid into the first upsert target" - [ 1, "age", Int 42; 1, "likes", String "Pizza"; 1, "name", String "Bob" ] + [ 1, "age", Int64 42L; 1, "likes", String "Pizza"; 1, "name", String "Bob" ] (datoms first Eavt ()); let second = empty_db ~schema:[ "name", unique_identity ] () |> db_with - [ Add (Temp_id "-1", "age", Int 42) + [ Add (Temp_id "-1", "age", Int64 42L) ; Add (Temp_id "-2", "likes", String "Pizza") ; Add (Temp_id "-2", "name", String "Bob") ; Add (Temp_id "-1", "name", String "Bob") @@ -349,7 +349,7 @@ let test_upsert__test_retries_order () = in assert_equal_triples "retry order preserves the first unique identity owner" - [ 2, "age", Int 42; 2, "likes", String "Pizza"; 2, "name", String "Bob" ] + [ 2, "age", Int64 42L; 2, "likes", String "Pizza"; 2, "name", String "Bob" ] (datoms second Eavt ()) let test_upsert__test_upsert_string_tempid_ref () = @@ -357,18 +357,18 @@ let test_upsert__test_upsert_string_tempid_ref () = empty_db ~schema:[ "name", unique_identity; "ref", ref_attr ] () |> db_with [ entity [ one "name" (String "Alice") ] ] in - let expected = [ 1, "name", String "Alice"; 2, "age", Int 36; 2, "ref", Ref 1 ] in + let expected = [ 1, "name", String "Alice"; 2, "age", Int64 36L; 2, "ref", Ref 1 ] in [ [ entity ~db_id:(Temp_id "user") [ one "name" (String "Alice") ] - ; entity [ one "age" (Int 36); one "ref" (Ref_to (Temp_id "user")) ] + ; entity [ one "age" (Int64 36L); one "ref" (Ref_to (Temp_id "user")) ] ] ; [ Add (Temp_id "user", "name", String "Alice") - ; entity [ one "age" (Int 36); one "ref" (Ref_to (Temp_id "user")) ] + ; entity [ one "age" (Int64 36L); one "ref" (Ref_to (Temp_id "user")) ] ] ; [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Alice") ] - ; entity [ one "age" (Int 36); one "ref" (Ref_to (Temp_id "-1")) ] + ; entity [ one "age" (Int64 36L); one "ref" (Ref_to (Temp_id "-1")) ] ] ; [ Add (Temp_id "-1", "name", String "Alice") - ; entity [ one "age" (Int 36); one "ref" (Ref_to (Temp_id "-1")) ] + ; entity [ one "age" (Int64 36L); one "ref" (Ref_to (Temp_id "-1")) ] ] ] |> List.iter (fun tx -> @@ -399,13 +399,13 @@ let test_upsert__test_vector_upsert () = empty_db ~schema:[ "name", unique_identity ] () |> db_with [ entity ~db_id:(Temp_id "-1") [ one "name" (String "Ivan") ] ] in - [ [ Add (Temp_id "-1", "name", String "Ivan"); Add (Temp_id "-1", "age", Int 12) ] - ; [ Add (Temp_id "-1", "age", Int 12); Add (Temp_id "-1", "name", String "Ivan") ] + [ [ Add (Temp_id "-1", "name", String "Ivan"); Add (Temp_id "-1", "age", Int64 12L) ] + ; [ Add (Temp_id "-1", "age", Int64 12L); Add (Temp_id "-1", "name", String "Ivan") ] ] |> List.iter (fun tx -> assert_equal_triples "vector add upsert resolves tempid into existing unique identity entity" - [ 1, "age", Int 12; 1, "name", String "Ivan" ] + [ 1, "age", Int64 12L; 1, "name", String "Ivan" ] (datoms (db_with tx db) Eavt ())); let db = empty_db ~schema:[ "name", unique_identity ] () @@ -422,9 +422,9 @@ let test_upsert__test_vector_upsert () = (transact db [ Add (Temp_id "-1", "name", String "Ivan") - ; Add (Temp_id "-1", "age", Int 35) + ; Add (Temp_id "-1", "age", Int64 35L) ; Add (Temp_id "-1", "name", String "Oleg") - ; Add (Temp_id "-1", "age", Int 36) + ; Add (Temp_id "-1", "age", Int64 36L) ])) let () = diff --git a/test/test_util.ml b/test/test_util.ml index ea4789d..c962708 100644 --- a/test/test_util.ml +++ b/test/test_util.ml @@ -30,12 +30,12 @@ let test_util__value_semantics () = let nested = Map [ Keyword "b", Vector [ String "x"; String "y" ] - ; Keyword "a", Set [ Int 2; Int 1; Int 1 ] + ; Keyword "a", Set [ Int64 2L; Int64 1L; Int64 1L ] ] in let normalized = Map - [ Keyword "a", Set [ Int 1; Int 2 ] + [ Keyword "a", Set [ Int64 1L; Int64 2L ] ; Keyword "b", Vector [ String "x"; String "y" ] ] in @@ -43,7 +43,7 @@ let test_util__value_semantics () = "Util.normalize_value normalizes unordered values without losing vector shape" normalized (Util.normalize_value nested); - if Util.compare_value (Vector [ Int 1; Int 2 ]) (List [ Int 1; Int 2 ]) = 0 then + if Util.compare_value (Vector [ Int64 1L; Int64 2L ]) (List [ Int64 1L; Int64 2L ]) = 0 then failf "vectors and lists must remain distinct values" let test_util__keyword_order_matches_upstream () = @@ -106,7 +106,7 @@ let test_util__keyword_order_matches_upstream () = failf "normalized nested filter map value ordering should match upstream DataScript value-compare" let test_util__vector_values_in_db () = - let vector = Vector [ Int 1; Map [ Keyword "tags", Vector [ Keyword "a"; Keyword "b" ] ] ] in + let vector = Vector [ Int64 1L; Map [ Keyword "tags", Vector [ Keyword "a"; Keyword "b" ] ] ] in let db = empty_db ~schema:[ "shape", indexed ] () |> db_with [ Add (Entity_id 1, "shape", vector) ] @@ -118,7 +118,7 @@ let test_util__vector_values_in_db () = assert_equal_triples "list values do not match vector values with the same members" [] - (datoms db Avet ~a:"shape" ~v:(List [ Int 1; Map [ Keyword "tags", Vector [ Keyword "a"; Keyword "b" ] ] ]) ()) + (datoms db Avet ~a:"shape" ~v:(List [ Int64 1L; Map [ Keyword "tags", Vector [ Keyword "a"; Keyword "b" ] ] ]) ()) let () = test_util__value_semantics (); diff --git a/type/datascript_types.ml b/type/datascript_types.ml index ba570cf..2202e9e 100644 --- a/type/datascript_types.ml +++ b/type/datascript_types.ml @@ -11,7 +11,7 @@ type entity_ref = and value = | Nil - | Int of int + | Int64 of int64 | Float of float | String of string | Symbol of string @@ -441,7 +441,7 @@ type query_arg = type query_form = | QueryFormNil | QueryFormBool of bool - | QueryFormInt of int + | QueryFormInt of int64 | QueryFormFloat of float | QueryFormString of string | QueryFormKeyword of string From 267cba2086161e5a7061cde4fdf3ed6470428218 Mon Sep 17 00:00:00 2001 From: zy C Date: Sat, 26 Sep 2026 01:47:15 -0700 Subject: [PATCH 2/3] fix: validate avet index access in public index lookups Upstream -datoms/-seek-datoms/-rseek-datoms/-index-range/find-datom all run validate-indexed: an :avet lookup on an attr that is not a ref, unique, or :db/index true raises "Attribute :x should be marked as :db/index true". Our datoms/datoms_list/fold_datoms/find_datom skipped the check (the stale comment claimed d/datoms is ISearch/-search; it is not). Internal paths that mirror -search keep the unvalidated search_datoms and now also follow upstream's fallback: an attr+value pattern on a non-indexed attr scans aevt filtered by value instead of probing avet. --- impl/datascript.ml | 75 +++++++++++++++++++++++++++++----------------- impl/db.ml | 27 ++++++++++++----- impl/db.mli | 1 + impl/db_access.ml | 3 ++ 4 files changed, 70 insertions(+), 36 deletions(-) diff --git a/impl/datascript.ml b/impl/datascript.ml index 87bc649..0427a7f 100644 --- a/impl/datascript.ml +++ b/impl/datascript.ml @@ -947,9 +947,40 @@ end) let entity_id_of_ref = Entity_refs_impl.entity_id_of_ref let resolve_ref_value = Entity_refs_impl.resolve_ref_value +let values_compare_equal_fast left right = + match left, right with + | Nil, Nil -> true + | Int64 left, Int64 right -> + left = right + | Ref left, Ref right -> + left = right + | Int64 left, Ref right -> + left = Int64.of_int right + | Ref left, Int64 right -> + Int64.of_int left = right + | String left, String right + | Symbol left, Symbol right + | Keyword left, Keyword right + | Uuid left, Uuid right + | Regex left, Regex right -> + left = right + | Bool left, Bool right -> left = right + | Instant left, Instant right -> left = right + | TxRef, TxRef -> true + | _ -> compare_value left right = 0 + +(* upstream -search db [nil attr v]: avet slice when the attr is indexed + (a ref, unique, or :db/index attr), else an aevt scan filtered by value *) +let search_attr_value db attr value = + if Db_access_impl.is_avet_accessible db attr then + Db_access_impl.datoms db Avet ~a:attr ~v:value () + else + Db_access_impl.search_datoms db Aevt ~a:attr () + |> Seq.filter (fun datom -> values_compare_equal_fast datom.v value) + let entity_context = { Entity.datoms_by_entity = (fun db entity_id -> datoms db Eavt ~e:entity_id ()) - ; datoms_by_avet_ref = (fun db attr entity_id -> datoms db Avet ~a:attr ~v:(Ref entity_id) ()) + ; datoms_by_avet_ref = (fun db attr entity_id -> search_attr_value db attr (Ref entity_id)) ; all_datoms = (fun db -> datoms db Eavt ()) ; compare_value ; cardinality @@ -990,7 +1021,7 @@ let pull_api_context : Pull_api_impl.context = ; entity_attrs ; datoms_by_entity = (fun db entity_id -> datoms db Eavt ~e:entity_id ()) ; all_datoms = (fun db -> datoms db Eavt ()) - ; datoms_by_avet_ref = (fun db attr entity_id -> datoms db Avet ~a:attr ~v:(Ref entity_id) ()) + ; datoms_by_avet_ref = (fun db attr entity_id -> search_attr_value db attr (Ref entity_id)) ; cardinality ; is_ref_attr ; is_component @@ -1179,28 +1210,6 @@ let resolve_query_value_for_attr db attr value = Option.map (fun entity_id -> Ref entity_id) (entid_ref db entity_ref) | _ -> resolve_query_value db value -let values_compare_equal_fast left right = - match left, right with - | Nil, Nil -> true - | Int64 left, Int64 right -> - left = right - | Ref left, Ref right -> - left = right - | Int64 left, Ref right -> - left = Int64.of_int right - | Ref left, Int64 right -> - Int64.of_int left = right - | String left, String right - | Symbol left, Symbol right - | Keyword left, Keyword right - | Uuid left, Uuid right - | Regex left, Regex right -> - left = right - | Bool left, Bool right -> left = right - | Instant left, Instant right -> left = right - | TxRef, TxRef -> true - | _ -> compare_value left right = 0 - let datoms_by_attr_value db attr value = match resolve_query_value_for_attr db attr value with | None -> [] @@ -2756,9 +2765,19 @@ module Query = struct let timestamp_datoms = match lower, upper with | Some lower, Some upper when values_compare_equal_fast lower upper -> - datoms db Avet ~a:timestamp_attr ~v:lower () - | Some lower, _ -> index_range db timestamp_attr ~start:lower () - | _, Some upper -> index_range db timestamp_attr ~stop:upper () + search_attr_value db timestamp_attr lower + | Some lower, _ -> + if Db_access_impl.is_avet_accessible db timestamp_attr then + index_range db timestamp_attr ~start:lower () + else + Db_access_impl.search_datoms db Aevt ~a:timestamp_attr () + |> Seq.filter (fun datom -> compare_value datom.v lower >= 0) + | _, Some upper -> + if Db_access_impl.is_avet_accessible db timestamp_attr then + index_range db timestamp_attr ~stop:upper () + else + Db_access_impl.search_datoms db Aevt ~a:timestamp_attr () + |> Seq.filter (fun datom -> compare_value datom.v upper <= 0) | None, None -> Seq.empty in let entity_ids = @@ -2916,7 +2935,7 @@ module Query = struct | None -> Some (Query_collection []) | Some class_id -> let tagged = - datoms db Avet ~a:"block/tags" ~v:(Ref class_id) () + search_attr_value db "block/tags" (Ref class_id) |> Seq.map (fun datom -> datom.e) |> List.of_seq |> List.sort_uniq compare diff --git a/impl/db.ml b/impl/db.ml index ce46057..ed00648 100644 --- a/impl/db.ml +++ b/impl/db.ml @@ -815,11 +815,13 @@ let resolved_entity_ref_option context db = Option.map (context.resolve_entity_r let resolved_value_option_for_optional_attr context db attr = Option.map (context.resolve_value_for_optional_attr db attr) -(* cljs d/datoms is ISearch/-search — it does not validate index access; - only -datoms/-seek-datoms/-rseek-datoms/-index-range/find-datom do. - An avet scan on a non-indexed attr simply yields nothing (avet only - stores avet-accessible datoms). *) -let datoms context db index ?e ?a ?v ?tx () = +(* cljs ISearch/-search (used by the query engine and entity reverse-attr + lookups) does not validate index access; an avet scan on a non-indexed + attr simply yields nothing (avet only stores avet-accessible datoms). + IIndexAccess entry points (d/datoms, d/find-datom, d/seek-datoms, + d/rseek-datoms, d/index-range) all run upstream's validate-indexed and + raise when the :avet attr is not a ref, unique, or :db/index true. *) +let search_datoms context db index ?e ?a ?v ?tx () = let v = resolved_value_option_for_optional_attr context db a v in let datoms, exact = let prefix_v, prefix_tx = @@ -845,7 +847,12 @@ let datoms context db index ?e ?a ?v ?tx () = in apply_filter_pred db datoms +let datoms context db index ?e ?a ?v ?tx () = + validate_index_access context db index a; + search_datoms context db index ?e ?a ?v ?tx () + let fold_datoms f init context db index ?e ?a ?v ?tx () = + validate_index_access context db index a; let v = resolved_value_option_for_optional_attr context db a v in let prefix_v, prefix_tx = match index, e, a, v with @@ -891,7 +898,7 @@ let fold_datoms f init context db index ?e ?a ?v ?tx () = | Some pred -> PSet.fold (fun acc datom -> if pred datom then f acc datom else acc) init (stored_index db index)) | _ -> - datoms context db index ?e ?a ?v ?tx () |> Seq.fold_left f init + search_datoms context db index ?e ?a ?v ?tx () |> Seq.fold_left f init let apply_filter_pred_list db datoms = match db.filter_pred with @@ -899,6 +906,7 @@ let apply_filter_pred_list db datoms = | Some pred -> List.filter pred datoms let datoms_list context db index ?e ?a ?v ?tx () = + validate_index_access context db index a; let v = resolved_value_option_for_optional_attr context db a v in let datoms, exact = let prefix_v, prefix_tx = @@ -925,8 +933,9 @@ let datoms_list context db index ?e ?a ?v ?tx () = apply_filter_pred_list db datoms let datoms_ref context db index ?e ?a ?v ?tx () = + validate_index_access context db index a; let e = resolved_entity_ref_option context db e in - datoms context db index ?e ?a ?v ?tx () + search_datoms context db index ?e ?a ?v ?tx () let find_datom context db index ?e ?a ?v ?tx () = datoms context db index ?e ?a ?v ?tx () |> Seq.uncons |> Option.map fst @@ -972,10 +981,11 @@ let seek_datoms context db index ?e ?a ?v ?tx () = match lower_prefix_datoms context db index e a v tx with | Some datoms -> apply_filter_pred db datoms | None -> - datoms context db index () + search_datoms context db index () |> Seq.filter (fun d -> compare_datom_to_bound context index d e a v tx >= 0) let seek_datoms_ref context db index ?e ?a ?v ?tx () = + validate_index_access context db index a; let e = resolved_entity_ref_option context db e in seek_datoms context db index ?e ?a ?v ?tx () @@ -990,6 +1000,7 @@ let rseek_datoms context db index ?e ?a ?v ?tx () = |> apply_filter_pred db let rseek_datoms_ref context db index ?e ?a ?v ?tx () = + validate_index_access context db index a; let e = resolved_entity_ref_option context db e in rseek_datoms context db index ?e ?a ?v ?tx () diff --git a/impl/db.mli b/impl/db.mli index a126513..ef40b45 100644 --- a/impl/db.mli +++ b/impl/db.mli @@ -42,6 +42,7 @@ type index_context = val indexed_attr_required_message : attr -> string val validate_index_access : index_context -> db -> index -> attr option -> unit val datoms : index_context -> db -> index -> ?e:entity_id -> ?a:attr -> ?v:value -> ?tx:tx -> unit -> datom Seq.t +val search_datoms : index_context -> db -> index -> ?e:entity_id -> ?a:attr -> ?v:value -> ?tx:tx -> unit -> datom Seq.t val fold_datoms : ('acc -> datom -> 'acc) -> 'acc -> diff --git a/impl/db_access.ml b/impl/db_access.ml index c055800..07fb967 100644 --- a/impl/db_access.ml +++ b/impl/db_access.ml @@ -99,6 +99,9 @@ end) = struct let datoms db index ?e ?a ?v ?tx () = Db.datoms db_index_context db index ?e ?a ?v ?tx () + let search_datoms db index ?e ?a ?v ?tx () = + Db.search_datoms db_index_context db index ?e ?a ?v ?tx () + let fold_datoms f init db index ?e ?a ?v ?tx () = Db.fold_datoms f init db_index_context db index ?e ?a ?v ?tx () From e3454ba7e127240503b90482bd17ac1d77c84280 Mon Sep 17 00:00:00 2001 From: zy C Date: Sat, 26 Sep 2026 01:47:15 -0700 Subject: [PATCH 3/3] test: fix stale expectations masked by earlier failures - entity materialization reads only the entity's own eavt datoms since 9284149; the scan counter assertion still expected one all-datoms scan. - the shared-tempids test listed expected datoms in insertion order, but datoms :eavt returns attr-sorted results (friend < name < parent). --- test/test_datascript.ml | 2 +- test/test_entity.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_datascript.ml b/test/test_datascript.ml index ddb2e1b..06c5aec 100644 --- a/test/test_datascript.ml +++ b/test/test_datascript.ml @@ -1736,8 +1736,8 @@ let test_tempid_shared_between_entity_id_and_ref_values () = assert_equal_triples "value-position tempids share the entity-id tempid's allocation" [ e1, "name", String "Ivan" - ; e2, "name", String "Petr" ; e2, "friend", Ref e1 + ; e2, "name", String "Petr" ; e2, "parent", Ref e1 ] (datoms report.db_after Eavt ()) diff --git a/test/test_entity.ml b/test/test_entity.ml index 28ccf17..b476fc5 100644 --- a/test/test_entity.ml +++ b/test/test_entity.ml @@ -340,7 +340,7 @@ let test_entity__test_entity_attr_lookup_is_lazy () = ignore (Entity.entity_attr context entity "_friend"); assert_equal_int "reverse attr lookup should use AVET instead of all datoms" 0 !all_datoms_calls; ignore (Entity.entity_attrs entity); - assert_equal_int "full entity materialization may scan all datoms once" 1 !all_datoms_calls + assert_equal_int "full entity materialization only reads the entity's own datoms" 0 !all_datoms_calls let () = test_entity__test_entity ();