mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-12-01 15:37:14 +00:00
new comparison method Ine (caseInsensitive notEquals) (#1551)
This commit is contained in:
1 parent
7be4675d3e
commit
4fe2016891
22 files changed
+1487
-1008
No files matched your search
+1
-1
@@ -8,7 +8,7 @@ import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
public class CaseInsensitiveEqualExpressionTest extends BaseExpressionTest {
|
||||
|
||||
CaseInsensitiveEqualExpression exp(String propName, String value) {
|
||||
return new CaseInsensitiveEqualExpression(propName, value);
|
||||
return new CaseInsensitiveEqualExpression(propName, value, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.Expression;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
@@ -8,6 +10,12 @@ import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
|
||||
public class DefaultExpressionFactoryTest {
|
||||
|
||||
private String toQueryPlanHash(Expression expression) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
((SpiExpression)expression).queryPlanHash(sb);
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testLowerILike() throws Exception {
|
||||
|
||||
@@ -30,6 +38,7 @@ public class DefaultExpressionFactoryTest {
|
||||
DefaultExpressionFactory factory = new DefaultExpressionFactory(false, false);
|
||||
Expression expression = factory.eq("name", null);
|
||||
assertThat(expression).isInstanceOf(NullExpression.class);
|
||||
assertThat(toQueryPlanHash(expression)).isEqualTo("Null[name]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -38,14 +47,24 @@ public class DefaultExpressionFactoryTest {
|
||||
DefaultExpressionFactory factory = new DefaultExpressionFactory(false, false);
|
||||
Expression expression = factory.ne("name", null);
|
||||
assertThat(expression).isInstanceOf(NullExpression.class);
|
||||
assertThat(toQueryPlanHash(expression)).isEqualTo("NotNull[name]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIeq() throws Exception {
|
||||
|
||||
DefaultExpressionFactory factory = new DefaultExpressionFactory(false, false);
|
||||
Expression expression = factory.ieq("name", null);
|
||||
assertThat(expression).isInstanceOf(NullExpression.class);
|
||||
assertThat(toQueryPlanHash(expression)).isEqualTo("Null[name]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIne() throws Exception {
|
||||
|
||||
DefaultExpressionFactory factory = new DefaultExpressionFactory(false, false);
|
||||
Expression expression = factory.ine("name", null);
|
||||
assertThat(expression).isInstanceOf(NullExpression.class);
|
||||
assertThat(toQueryPlanHash(expression)).isEqualTo("NotNull[name]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -83,6 +83,15 @@ public class EqlParserTest extends BaseTestCase {
|
||||
assertThat(query.getGeneratedSql()).contains("where lower(t0.name) =?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_ine() {
|
||||
|
||||
Query<Customer> query = parse("where name ine 'Rob'");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where lower(t0.name) !=?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_ieq_reverse() {
|
||||
|
||||
@@ -91,6 +100,15 @@ public class EqlParserTest extends BaseTestCase {
|
||||
assertThat(query.getGeneratedSql()).contains("where lower(t0.name) =?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_ine_reverse() {
|
||||
|
||||
Query<Customer> query = parse("where 'Rob' ine name");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("where lower(t0.name) !=?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void where_eq2() {
|
||||
|
||||
|
||||
Reference in new issue
Block a user