question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Number array parameter parsed as string array

See original GitHub issue

I am not able to use an array of numbers as a parameter

var keep = [1, 2, 3]

// this does not work
client.query('delete from foo where key_one=$1 and key_two not in($2)', [id, keep], function(err, result) {
    // handle result
})

gives this error

invalid input syntax for integer: "{"1","2","3"}"

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thom4parisotcommented, Jun 25, 2020

@camsteffen you mean is replacing field IN (<array_of_int>) by field = ANY(<array_of_int>) is what makes it work? Very subtle. Thank you 😃

0reactions
camsteffencommented, May 2, 2016

I figured it out. My query was formed wrong but it is actually possible to use a number array as a parameter.

var keep = [1, 2, 3]
client.query('delete from foo where key_one=$1 and not key_two = any($2)', [id, keep], function(err, result) {
    // handle result
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

why does javascript parse an array as a string when passed in ...
When two numbers are added, an integer is output. However, 2 and hello can't be added numerically, so everything is first automatically ...
Read more >
Array[number] query params is NOT correctly parsed. #5793
Description. Parsing array value from argument decorated by @param. array() has bug, it doesn't respect the item type specified for each item.
Read more >
Passing arrays as arguments - C# Programming Guide
Arrays can be passed as arguments to method parameters. Because arrays are reference types, the method can change the value of the elements....
Read more >
parse_str - Manual - PHP
Parses string as if it were the query string passed via a URL and sets variables in the current scope (or in the...
Read more >
How to Parse a Query string Array Parameter using - Apigee
Is there any particular query parameter format I must use in the GET runstring but it appears I am unable to parse an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found