-
-
Notifications
You must be signed in to change notification settings - Fork 270
Description
Rewriting this into an issue since we were advised that it'll be more useful than a Google Group post π :
Expected behavior
Properties named 'in' can be used in Java code by specifying a different column name using the @column annotation.
Actual behavior
Properties named 'in' with a @column annotation produce SQL syntax errors since the SQL keyword 'in' is also being replaced by the column name specified for the property.
For example, if we have a property named 'in' with a @column(name="inputName") annotation and the correctly created SQL would be:
select t0.id, t0.status, t0.name, t0.inputName, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.billing_address_id, t0.shipping_address_id from o_customer t0 where t0.name in (?,?)
the SQL-"in" of the where clause also mistakenly gets replaced by the column name, producing
select t0.id, t0.status, t0.name, t0.inputName, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.billing_address_id, t0.shipping_address_id from o_customer t0 where t0.name t0.inputName (?,?)
which leads to a SQLException due to invalid syntax.
Steps to reproduce
Add a property named 'in' with an arbitrary column name by using @column(name = "...") to any entity, for example Customer in ebean-test:
@Size(max = 40)
@Column(name = "inputName")
String in;And start all tests, which will produce several failures, for example EqlParserTest.where_in_when_namedParams_withNoWhitespace:
Error: Tests run: 83, Failures: 0, Errors: 7, Skipped: 3, Time elapsed: 0.311 s <<< FAILURE! - in io.ebean.xtest.internal.server.grammer.EqlParserTest
Error: io.ebean.xtest.internal.server.grammer.EqlParserTest.where_in_when_namedParams_withNoWhitespace Time elapsed: 0.003 s <<< ERROR!
javax.persistence.PersistenceException:
Query threw SQLException:Syntax error in SQL statement "select t0.id, t0.status, t0.name, t0.inputName, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.billing_address_id, t0.shipping_address_id from o_customer t0 where t0.name [*]t0.inputName (?,?)"; SQL statement:
select t0.id, t0.status, t0.name, t0.inputName, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.billing_address_id, t0.shipping_address_id from o_customer t0 where t0.name t0.inputName (?,?) [42000-212] Bind values:[null] Query was:select t0.id, t0.status, t0.name, t0.inputName, t0.smallnote, t0.anniversary, t0.cretime, t0.updtime, t0.version, t0.billing_address_id, t0.shipping_address_id from o_customer t0 where t0.name t0.inputName (?,?)