Please use the google group to ask questions - thanks.

by florin 12 Jan 17:15
Parameter asignment operator conflicting with type conversion in PostgreSql

Found that

"from my_table where my_cal =: param" is creating conflicts with the type conversion operator in PostgreSql:

"from my_table where my_cal =: param and my_tstamp1::date - my_tstamp2::date > 0" would not do.

Any workaround, escaping?


12 Jan 21:00
by Rob

Can you try putting a space before :param ... and no space between ":" and "param"

"from my_table where my_cal = :param and ... "

Does that work?

12 Jan 22:21
by Rob

Unless... Ebean is thinking that :date is a named parameter in .. " my_tstamp1::date "

so ...

"from my_table where my_cal =: param and my_tstamp1::date - my_tstamp2::date > 0"

Ebean probably (haven't checked yet) ... sees :param, :date and :date as 3 named parameters in the above. Hmmm...

12 Jan 23:57
by florin


I did try variations. Indeed Ebean takes the :date as a named parameter.

Maybe escaping would do = \:\:date?

13 Jan 22:50
by Rob

Looks like we could use a different form for casting the timestamp to a date with Postgres.

that is use:
SELECT CAST(your-timestamp-value AS date)

rather than:
SELECT your-timestamp-value::date

So the statement would become...

... my_cal = :param and CAST(my_tstamp1 as date) - CAST(my_tstamp2 as date) > 0

That should get around the issue of ::date being treated as a named parameter. Is that a good enough workaround?

Thanks, Rob.

17 Feb 05:53
by florin

Thank you.

Create a New Topic

Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements