mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge branch 'wip/eql1' into wip/eql2
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.avaje.ebeaninternal.server.grammer;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class EqlParserTest {
|
||||
|
||||
@Test
|
||||
public void where_eq() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name eq 'Rob'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_eq2() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name = 'Rob'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where t0.name = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_or1() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where name = 'Rob' or (status = 'NEW' and smallnote is null)");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where (t0.name = ? or (t0.status = ? and t0.smallnote is null ) )");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_or2() throws Exception {
|
||||
|
||||
Query<Customer> query = parse("where (name = 'Rob' or status = 'NEW') and smallnote is null");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where ((t0.name = ? or t0.status = ? ) and t0.smallnote is null )");
|
||||
}
|
||||
|
||||
private Query<Customer> parse(String raw) {
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class);
|
||||
EqlParser.parse(raw, query);
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user