DDC-1530: HIDDEN values cannot be used in WhereClause #1920

Closed
opened 2026-01-22 13:31:33 +01:00 by admin · 10 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 12, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user @guilhermeblanco:

SELECT  u, u.name AS HIDDEN n FROM User u WHERE n = ?1

Is broken. Error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sclr16' in 'where clause

On a query like:

SELECT s0*.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0_ WHERE s0*.a = 1 AND sclr16 <= ? ORDER BY sclr16 ASC 
Originally created by @doctrinebot on GitHub (Dec 12, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user @guilhermeblanco: ``` SELECT u, u.name AS HIDDEN n FROM User u WHERE n = ?1 ``` Is broken. Error: ``` SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sclr16' in 'where clause ``` On a query like: ``` SELECT s0*.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0_ WHERE s0*.a = 1 AND sclr16 <= ? ORDER BY sclr16 ASC ```
admin added the ImprovementInvalid labels 2026-01-22 13:31:35 +01:00
admin closed this issue 2026-01-22 13:31:35 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 20, 2011):

Comment created by @guilhermeblanco:

Updating fix version

@doctrinebot commented on GitHub (Dec 20, 2011): Comment created by @guilhermeblanco: Updating fix version
Author
Owner

@doctrinebot commented on GitHub (Jan 9, 2012):

Comment created by craue:

It occurs even if the value is not HIDDEN.

@doctrinebot commented on GitHub (Jan 9, 2012): Comment created by craue: It occurs even if the value is not HIDDEN.
Author
Owner

@doctrinebot commented on GitHub (Jan 10, 2012):

Comment created by @beberlei:

@Christian this sounds like a completly different error, please explain why you think this belongs here or open a new ticket.

@doctrinebot commented on GitHub (Jan 10, 2012): Comment created by @beberlei: @Christian this sounds like a completly different error, please explain why you think this belongs here or open a new ticket.
Author
Owner

@doctrinebot commented on GitHub (Jan 10, 2012):

Comment created by craue:

Benjamin: Because I get exactly the same error message regardless of using HIDDEN. So HIDDEN doesn't seem to be liable here.

@doctrinebot commented on GitHub (Jan 10, 2012): Comment created by craue: Benjamin: Because I get exactly the same error message regardless of using HIDDEN. So HIDDEN doesn't seem to be liable here.
Author
Owner

@doctrinebot commented on GitHub (Jan 10, 2012):

Comment created by @beberlei:

Can you paste your DQL and SQL?

@doctrinebot commented on GitHub (Jan 10, 2012): Comment created by @beberlei: Can you paste your DQL and SQL?
Author
Owner

@doctrinebot commented on GitHub (Jan 10, 2012):

Comment created by craue:

Code:

$queryBuilder
    ->select('myEntity, 123456789 AS distance')
    ->where('distance <= 10')
;

DQL:

SELECT myEntity, 123456789 AS distance FROM MyCompany\MyBundle\Entity\MyEntity myEntity WHERE distance <= 10

SQL:

SELECT s0*.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0* WHERE sclr16 <= 10
@doctrinebot commented on GitHub (Jan 10, 2012): Comment created by craue: Code: ``` $queryBuilder ->select('myEntity, 123456789 AS distance') ->where('distance <= 10') ; ``` DQL: ``` SELECT myEntity, 123456789 AS distance FROM MyCompany\MyBundle\Entity\MyEntity myEntity WHERE distance <= 10 ``` SQL: ``` SELECT s0*.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0* WHERE sclr16 <= 10 ```
Author
Owner

@doctrinebot commented on GitHub (Jan 11, 2012):

Comment created by @beberlei:

That is expected behavior, ANSI SQL defines SELECT to be evaluated AFTER WHERE.

SELECT 1234 AS foo FROM `test` HAVING foo = 1234

DQL has a HAVING clause as well, not sure it works without the group by. Please try.

@doctrinebot commented on GitHub (Jan 11, 2012): Comment created by @beberlei: That is expected behavior, ANSI SQL defines SELECT to be evaluated **AFTER** WHERE. ``` SELECT 1234 AS foo FROM `test` HAVING foo = 1234 ``` DQL has a HAVING clause as well, not sure it works without the group by. Please try.
Author
Owner

@doctrinebot commented on GitHub (Jan 21, 2012):

Comment created by craue:

So we might just close this issue then?

@doctrinebot commented on GitHub (Jan 21, 2012): Comment created by craue: So we might just close this issue then?
Author
Owner

@doctrinebot commented on GitHub (Jan 25, 2012):

Comment created by @beberlei:

Its not a bug, just the error message is supposed to be improved (if possible) in a cheap way.

@doctrinebot commented on GitHub (Jan 25, 2012): Comment created by @beberlei: Its not a bug, just the error message is supposed to be improved (if possible) in a cheap way.
Author
Owner

@malukenho commented on GitHub (Jan 5, 2017):

@Ocramius @guilhermeblanco can be closed as invalid?

@malukenho commented on GitHub (Jan 5, 2017): @Ocramius @guilhermeblanco can be closed as invalid?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1920