-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search an integer array fails, invalid syntax for integer #2495
Comments
SELECT * FROM table1 WHERE field1 @> $1 |
Thanks for the quick reply! I know the Intarray extension on an Integer multi-array requires to use {}. I would have felt pretty silly if it was a straight forward application. I changed to above and got the following errors: |
When you pass the parameter, it needs to be as an array (or the string form of an array). So if you had: client.query("SELECT * FROM table1 WHERE field1 @> $1 AND guid = $2", [619327, someGuid]) the version with a correct parameter value would be this: client.query("SELECT * FROM table1 WHERE field1 @> $1 AND guid = $2", [[619327], someGuid]) Or, if the parameter is always one element, you can make the array in the query: client.query("SELECT * FROM table1 WHERE field1 @> ARRAY[$1] AND guid = $2", [619327, someGuid]) |
The first option worked, thanks for the feedback! |
I am referencing JSON / Array issue #442
RN - 65
Node - 14
Express - 4.1
I have a very simple PG Query that works fine in Postgre:
SELECT * from table1 where field1 @> '{619327}'
Field1 is an Integer Array with intarray extension, index.
In PG Tried Several Iterations with no success ->
const url = "SELECT * from table1 where field1 @> '{$1}' Error: invalid input syntax for type integer: "$1" at character 45
const url = "SELECT * from table1 where field1 @> '${1}'::json
const url = "SELECT * from table1 where field1 @> '$1'::json
const url = "SELECT * from table1 where field1 @> '{$1}'::jsonb
const url = "SELECT * from table1 where field1 @> '$1'::jsonb Error:Token Invalid. :CONTEXT: JSON data, line 1: $...
return client.query(url, addValues)
I saw #442 and tried a few things. I am not exactly sure what to do. Anyone solve this problem for an Integer?
Struggling.
The text was updated successfully, but these errors were encountered: