parameterization is not working correctly for FROM queries
See original GitHub issueIf I use the FROM
syntax during an UPDATE
statement, it seems that the parameterize of this library always assumes “text” event when it shouldn’t be. I have written a fully working example here: https://gist.github.com/nhumrich/d330d167b4650f32cc33cfcb992123c0
If you run a basic query where bar
is a DOUBLE PRECISION
column, everything works. But if you use this syntax instead, it says its text for some reason:
'UPDATE foo d SET bar=v.bar FROM (values ($1, $2)) as v(id,bar) WHERE d.id=v.id', ['abc', 4]
You get the following error form postgres:
error: column “bar” is of type double precision but expression is of type text
If I dont use parameters, and instead use the exact values in the query, it works perfectly, as expected. You can see this example in the gist. Obviously, “not using parameters” is not a workaround, because of sql injection.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top GitHub Comments
Thats fair. I did try other libraries in other languages though, like sqlalchemy (python, which has the same mapping problem as javascript), and none of them have this problem. I will look into this though.
I see the same issue but for UPDATE queries that use the CASE/WHEN syntax like
See the full script at https://gist.github.com/shaneosullivan/555419454e536823d6f56fbc04612096