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.

How to provide values of complex types to parameterized statements?

See original GitHub issue

For instance, how can I use node-postgres to execute the parameterized statement SELECT $1::circle[] with the value ARRAY[ '<(0, 0), 1>'::circle ] assigned to $1?

None of the following work:

  • client.query('SELECT $1::circle[]', [ [{ x: 0, y: 0, radius: 1 }] ])
  • client.query('SELECT $1::circle[]', ['{ <(0, 0),1> }'])
  • client.query('SELECT $1::circle[]', [`'{ <(0,0),1>'::circle }`])
  • client.query('SELECT $1::circle[]', [`ARRAY[ '<(0,0),1>'::circle ]`])

All fail with error: invalid input syntax for type circle: "<(0" or similar.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
charmandercommented, Aug 10, 2021

To be clear, this should work too:

client.query('SELECT $1::circle[]', [['<(0,0),1>']])
0reactions
Quelklefcommented, Aug 10, 2021

Holy shit, thank you so much! Seriously, I’ve spent hours on this, and you’ve solved it in a single sentence. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Query Parameterization - OWASP Cheat Sheet Series
Dynamic SQL can be parameterized using bind variables, to ensure the dynamically constructed SQL is secure. Here are some examples of using bind...
Read more >
Parameterized Queries | SQL Tutorial Documentation on data ...
Declare statements start with the keyword DECLARE , followed by the name of the parameter (starting with a question mark) followed by the...
Read more >
Using parameterized queries - Amazon Athena
Use parameterized queries in Athena to re-run the same query with different values and avoid SQL injection attacks.
Read more >
Create a parameter query (Power Query) - Microsoft Support
Use a parameter to change a data source · Select Home > Manage Parameters > New Parameter. · Enter the following information in...
Read more >
Parameterized SQL Queries | Historian 7.2 Documentation
Parameterized SQL queries allow you to place parameters in an SQL query instead of a constant value. A parameter takes a value only...
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