doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.95k stars 2.52k forks source link

Boolean expressions (like comparison expressions, without the comparison) #5959

Open teohhanhui opened 8 years ago

teohhanhui commented 8 years ago

From jsor/doctrine-postgis#14

The following DQL:

SELECT b
FROM AppBundle\Entity\EntityB b
INNER JOIN AppBundle\Entity\EntityA a
    WITH ...
    AND ST_Contains(a.geom, b.geom)
WHERE
...

gives

Error: Expected =, <, <=, <>, >, >=, !=, got 'WHERE'

The workaround is to change it to:

ST_Contains(a.geom, b.geom) = true

It'd be great if the DQL parser would support boolean expressions.

DaDeather commented 5 years ago

Another Information to note is that in this case a spatial index is being omitted when comparing the return value of these spatial functions.

ksaveras commented 4 years ago

👍

wouterj commented 3 years ago

I'm willing to help work on this, as this is quite limiting for us (as @DaDeather mentioned, DQL at the moment only allows writing queries that completely omit any spatial index).

However, this seems quite some task for someone that never contributed to Doctrine, so I would like some guidance if possible :). As a start: does this have a possibility of being accepted if implemented as suggested in the description? and where do I add tests for this? (I don't see much tests in ParserTest and I'm unsure where to put them)

cte-silico commented 2 years ago

Hello,

I have the same issue with SQL server "contains" fulltext search function that does not accept comparison. Here is the DQL:

SELECT count(s.id) FROM AppBundle\Entity\Scan s INNER JOIN s.documents documents WITH documents.num=1 WHERE contains(documents.name,'ppc') AND charindex(:value_62d6c8746d9f7,documents.name,0) >= 0

I cannot change contains(...) to contains(...) = true since SQL server does not allow it (raise error on =)

I'm stuck with this and cannot do a raw query

It is legitimate to allow Expr/Func as conditions since it is native sql query conditions