Nicola Gabriel
Nicola Gabriel

Reputation: 1

Symfony2 Doctrine CAST AS DECIMAL

I use Sonata Admin Bundle in Symfony2 and have a custom filter. In database, column is float (cannot change it). If you type 1333.33 there will be no result.

One solution is to use CAST:

CAST( o.price AS DECIMAL) = CAST( 399.99 AS DECIMAL)

Query is working just fine in SQL but Doctrine throws an error. So my question is how can use CAST in Doctrine or another reliable solution?

Upvotes: 0

Views: 2366

Answers (1)

stollr
stollr

Reputation: 7233

Doctrine does not provide a CAST construct in its DQL (see this list).

But for your special case, it should be enough to compare the values multiplyed by 100:

o.price * 100 = 399.99 * 100

Upvotes: 1

Related Questions