You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NamedQuery error when use PostgreSQL type cast ::int #428
When I use NamedQuery for PostgreSQL and use type cast ::int in query:
SELECT (d.categories->>0)::int AS category_id
FROM some_table d
WHERE id =:id
I get error:
error="pq: syntax error at or near \":\""
if I use CAST
SELECT CAST(d.categories->>0 AS integer) AS category_id
FROM some_table d
WHERE id =:id
query works fine
Reacted by Jeremy Kaplan, Joel Southcott, Alan Braithwaite, Stas Karkavin, Artem Astapenko, Zach Henwood, Jonas Zeitler, Alex Efros, Pavel Kilin, Michael Manganiello and 1 more
Just spotted this but I'm guessing it's because you're using a NamedStmt which requires you to double escape all :. Your generated query will only be providing one : to PostgreSQL and then failing.
Try changing to:
SELECT (d.categories->>0)::::int AS category_id
Reacted by Ketan Iralepatil, Adam Szecówka and JessePerry
Activity
kisamoto commentedon Jul 15, 2019
Just spotted this but I'm guessing it's because you're using a
NamedStmtwhich requires you to double escape all:. Your generated query will only be providing one:to PostgreSQL and then failing.Try changing to:
powerman commentedon Jul 27, 2019
@kisamoto Thanks. Is this way to double-escape
:documented?kisamoto commentedon Jul 28, 2019
@powerman I didn't find it in the docs, instead I noticed it searching for a similar problem that led me to #91
quenbyako commentedon Sep 22, 2023