-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
If 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.