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

Open
opened 2026-01-22 15:01:32 +01:00 by admin · 4 comments
Owner

Originally created by @teohhanhui on GitHub (Aug 2, 2016).

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.

Originally created by @teohhanhui on GitHub (Aug 2, 2016). From jsor/doctrine-postgis#14 The following DQL: ``` sql 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: ``` sql ST_Contains(a.geom, b.geom) = true ``` It'd be great if the DQL parser would support boolean expressions.
Author
Owner

@DaDeather commented on GitHub (Apr 29, 2019):

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

@DaDeather commented on GitHub (Apr 29, 2019): Another Information to note is that in this case a spatial index is being omitted when comparing the return value of these spatial functions.
Author
Owner

@ksaveras commented on GitHub (Apr 8, 2020):

👍

@ksaveras commented on GitHub (Apr 8, 2020): 👍
Author
Owner

@wouterj commented on GitHub (Jan 7, 2021):

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)

@wouterj commented on GitHub (Jan 7, 2021): 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)
Author
Owner

@cte-silico commented on GitHub (Jul 19, 2022):

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

@cte-silico commented on GitHub (Jul 19, 2022): 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5205