mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1483 - Invalid SQL with allQuotedIdentifiers true - where t0.[t0.[COND]] in (?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
This commit is contained in:
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.deploy;
|
||||
import io.ebean.BaseTestCase;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Address;
|
||||
import org.tests.model.basic.BWithQIdent;
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -14,6 +15,8 @@ public class DeployPropertyParserTest extends BaseTestCase {
|
||||
|
||||
private final BeanDescriptor<Address> addressBeanDescriptor = getBeanDescriptor(Address.class);
|
||||
|
||||
private final BeanDescriptor<BWithQIdent> bWithQIdentDescriptor = getBeanDescriptor(BWithQIdent.class);
|
||||
|
||||
@Test
|
||||
public void from_prefix_expect_unchanged() {
|
||||
assertThat(parser().parse("(select x from status join status)")).isEqualTo("(select x from status join status)");
|
||||
@@ -49,6 +52,12 @@ public class DeployPropertyParserTest extends BaseTestCase {
|
||||
assertThat(addressParser().parse("concat(line1, line2, '-EA')")).isEqualTo("concat(${}line_1, ${}line_2, '-EA')");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withQuote_when_match() {
|
||||
assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}\"Name\" like ?");
|
||||
assertThat(withQuoteParser().parse("t0.\"CODE\" like ?")).isEqualTo("t0.\"CODE\" like ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknown_path() {
|
||||
assertThat(parser().parse(" foo ")).isEqualTo(" foo ");
|
||||
@@ -62,4 +71,8 @@ public class DeployPropertyParserTest extends BaseTestCase {
|
||||
return addressBeanDescriptor.parser();
|
||||
}
|
||||
|
||||
private DeployPropertyParser withQuoteParser() {
|
||||
return bWithQIdentDescriptor.parser();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@@ -18,6 +17,9 @@ public class BWithQIdent {
|
||||
@Size(max = 191) // key must not exceed 767 Bytes, so max key len for mysql with utf8mb4 = 191*4 = 764 bytes
|
||||
String name;
|
||||
|
||||
@Column(name = "`CODE`")
|
||||
String CODE;
|
||||
|
||||
@Version
|
||||
Timestamp lastUpdated;
|
||||
|
||||
@@ -37,6 +39,14 @@ public class BWithQIdent {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCODE() {
|
||||
return CODE;
|
||||
}
|
||||
|
||||
public void setCODE(String CODE) {
|
||||
this.CODE = CODE;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.tests.quotedidentifier;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.BWithQIdent;
|
||||
|
||||
public class TestQuotedIdentifierQuery extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
BWithQIdent bean = new BWithQIdent();
|
||||
bean.setName("foo");
|
||||
bean.setCODE("bar");
|
||||
|
||||
Ebean.save(bean);
|
||||
|
||||
Ebean.find(BWithQIdent.class)
|
||||
.where()
|
||||
.eq("name", "foo")
|
||||
.raw("t0.\"Name\" = ?", "foo")
|
||||
.raw("t0.\"CODE\" = ?", "bar")
|
||||
.findList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user