0

I'm writing a Dropwizard app that needs to connect to the database, and using SQL objects to query the DB, per the Dropwizard docs.

The issue I'm running into is when my query is using a type specifier (::) being confused for a binding variable. Something like

SELECT (a, b, c)::user_type FROM ... WHERE id = :id

The parser is reading ::user_type as a parameter placeholder. When I've escaped them with \, it says the query is not returning any rows, but if I run the query through psql, it does, so I'm guessing it's not so simple. Any help would be appreciated.

Thanks! :D

pablo.meier
  • 2,339
  • 4
  • 21
  • 29

1 Answers1

0

The easiest solution is to just use the SQL-standard CAST syntax not the PostgreSQL extension :: syntax.

CAST (c AS user_type)
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778