Skip to content

Commit cd41822

Browse files
committed
fix rosetta psql issue (could not determine data type of parameter) by always casting field to its type when checking if null
1 parent aa12df7 commit cd41822

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/app/rosetta/lib/search.ml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -240,39 +240,35 @@ module Sql = struct
240240
~op_status_field ~address_fields ~op_type_filters operator =
241241
let values_for_filter = function
242242
| `Block_height ->
243-
("<=", 1, None)
243+
("<=", 1, "int")
244244
| `Txn_hash ->
245-
("=", 2, None)
245+
("=", 2, "text")
246246
| `Account_identifier_pk ->
247-
("=", 3, None)
247+
("=", 3, "text")
248248
| `Account_identifier_token ->
249-
("=", 4, None)
249+
("=", 4, "text")
250250
| `Op_status ->
251-
("=", 5, Some "transaction_status")
251+
("=", 5, "transaction_status")
252252
| `Success ->
253-
("=", 6, Some "transaction_status")
253+
("=", 6, "transaction_status")
254254
| `Address ->
255-
("=", 7, None)
255+
("=", 7, "text")
256256
in
257257
let gen_filter (op_1, op_2, null_cmp) l =
258258
String.concat ~sep:[%string " %{op_1} "]
259259
@@ List.map l ~f:(function
260-
| ((_, (_, n, _)) :: _) :: _ as field_n_l ->
260+
| ((_, (_, n, typ)) :: _) :: _ as field_n_l ->
261261
let filters =
262262
String.concat ~sep:" OR "
263263
@@ List.map field_n_l ~f:(fun l ->
264264
String.concat ~sep:" AND "
265-
@@ List.map l
266-
~f:(fun (field', (cmp_op, n', cast_opt)) ->
267-
Option.value_map cast_opt
268-
~default:
269-
[%string "%{field'} %{cmp_op} $%{n'#Int}"]
270-
~f:(fun cast ->
271-
[%string
272-
"%{field'} %{cmp_op} CAST($%{n'#Int} AS \
273-
%{cast})"] ) ) )
265+
@@ List.map l ~f:(fun (field', (cmp_op, n', cast)) ->
266+
[%string
267+
"%{field'} %{cmp_op} CAST($%{n'#Int} AS \
268+
%{cast})"] ) )
274269
in
275-
[%string "($%{n#Int} %{null_cmp} NULL %{op_2} (%{filters}))"]
270+
[%string
271+
"($%{n#Int}::%{typ} %{null_cmp} NULL %{op_2} (%{filters}))"]
276272
| _ ->
277273
"" )
278274
in

0 commit comments

Comments
 (0)