Closed mvysny closed 6 years ago
The workaround would be to use HAVING instead of WHERE with MySQL, but it's slower and not actually supported by the PostgreSQL (actually it looks like it's supported by newer PostgreSQLs 9.x - evaluate).
All of the following databases fail to execute this statement:
SELECT count(*) FROM (select p.name as personName from Test p where 1=1 and personName = ? order by 1=1 ) AS Foo
The error message is 'unknown column personName'.
Ok, it's explicitly mentioned in PostgreSQL SELECT documentation:
An output column's name can be used to refer to the column's value in ORDER BY and GROUP BY clauses, but not in the WHERE or HAVING clauses; there you must write out the expression instead.
Fixed in vok-orm 0.9
MySQL nor PostgreSQL does not support aliases in WHERE clauses: https://stackoverflow.com/questions/942571/using-column-alias-in-where-clause-of-mysql-query-produces-an-error Therefore we can't use the java bean property names when constructing the WHERE clause, but we must use the actual column names.