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

Open
doctrinebot opened this Issue Dec 12, 2011 · 9 comments

2 participants

@doctrinebot

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 
@doctrinebot

Comment created by @guilhermeblanco:

Updating fix version

@doctrinebot

Comment created by craue:

It occurs even if the value is not HIDDEN.

@doctrinebot

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

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

Comment created by @beberlei:

Can you paste your DQL and SQL?

@doctrinebot

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

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

Comment created by craue:

So we might just close this issue then?

@doctrinebot

Comment created by @beberlei:

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

@doctrinebot doctrinebot added this to the 2.x milestone Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment