mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1695 - For SQL Server like remove the binary collation (Latin1_General_BIN)
This commit is contained in:
@@ -126,6 +126,10 @@ public abstract class BaseTestCase {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public boolean isPlatformCaseSensitive() {
|
||||
return !isMySql() && !isSqlServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* MS SQL Server does not allow setting explicit values on identity columns
|
||||
* so tests that do this need to be skipped for SQL Server.
|
||||
|
||||
@@ -2,8 +2,6 @@ package org.tests.query;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
@@ -20,7 +18,6 @@ public class TestQueryFilterCaseInsensitive extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER})
|
||||
@Test
|
||||
public void testEq() {
|
||||
|
||||
@@ -30,7 +27,11 @@ public class TestQueryFilterCaseInsensitive extends BaseTestCase {
|
||||
.eq("name", "ROB") // case match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).isEmpty();
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(customers).isEmpty();
|
||||
} else {
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
customers = DB.find(Customer.class).where()
|
||||
.ieq("name", "ROB") // case insensitive match
|
||||
@@ -39,14 +40,17 @@ public class TestQueryFilterCaseInsensitive extends BaseTestCase {
|
||||
assertThat(customers).hasSize(1);
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER})
|
||||
@Test
|
||||
public void testNe() {
|
||||
List<Customer> customers = DB.find(Customer.class).where()
|
||||
.ne("name", "ROB") // case match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).hasSize(4);
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(customers).hasSize(4);
|
||||
} else {
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
customers = DB.find(Customer.class).where()
|
||||
.ine("name", "ROB") // case insensitive match
|
||||
@@ -56,14 +60,17 @@ public class TestQueryFilterCaseInsensitive extends BaseTestCase {
|
||||
|
||||
}
|
||||
|
||||
@IgnorePlatform(Platform.MYSQL)
|
||||
@Test
|
||||
public void testLike() {
|
||||
List<Customer> customers = DB.find(Customer.class).where()
|
||||
.like("name", "%O%") // case match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).isEmpty();
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(customers).isEmpty();
|
||||
} else {
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
customers = DB.find(Customer.class).where()
|
||||
.ilike("name", "%O%") // case insensitive match
|
||||
@@ -72,31 +79,36 @@ public class TestQueryFilterCaseInsensitive extends BaseTestCase {
|
||||
assertThat(customers).hasSize(4); // Rob / Fiona / Cust No address / NocCust
|
||||
}
|
||||
|
||||
@IgnorePlatform(Platform.MYSQL)
|
||||
@Test
|
||||
public void testContains() {
|
||||
List<Customer> customers = DB.find(Customer.class).where()
|
||||
.contains("name", "O") // case match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).isEmpty();
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(customers).isEmpty();
|
||||
} else {
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
customers = DB.find(Customer.class).where()
|
||||
.icontains("name", "O") // case insensitive match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).hasSize(4); // Rob / Fiona / Cust No address / NocCust
|
||||
|
||||
}
|
||||
|
||||
@IgnorePlatform(Platform.MYSQL)
|
||||
@Test
|
||||
public void testStartsWith() {
|
||||
List<Customer> customers = DB.find(Customer.class).where()
|
||||
.startsWith("name", "RO") // case match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).isEmpty();
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(customers).isEmpty();
|
||||
} else {
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
customers = DB.find(Customer.class).where()
|
||||
.istartsWith("name", "RO") // case insensitive match
|
||||
@@ -105,14 +117,17 @@ public class TestQueryFilterCaseInsensitive extends BaseTestCase {
|
||||
assertThat(customers).hasSize(1);
|
||||
}
|
||||
|
||||
@IgnorePlatform(Platform.MYSQL)
|
||||
@Test
|
||||
public void testEndsWith() {
|
||||
List<Customer> customers = DB.find(Customer.class).where()
|
||||
.endsWith("name", "OB") // case match
|
||||
.le("id", 4).findList();
|
||||
|
||||
assertThat(customers).isEmpty();
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(customers).isEmpty();
|
||||
} else {
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
|
||||
customers = DB.find(Customer.class).where()
|
||||
.iendsWith("name", "OB") // case insensitive match
|
||||
|
||||
@@ -40,7 +40,7 @@ public class TestLikeEscaping extends TransactionalTestCase {
|
||||
.where().startsWith("name", "_").findCount()
|
||||
).isEqualTo(1);
|
||||
|
||||
if (!isMySql()) {
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(DB.find(Customer.class)
|
||||
.where().startsWith("name", "_u").findCount()
|
||||
).isEqualTo(0);
|
||||
@@ -50,7 +50,7 @@ public class TestLikeEscaping extends TransactionalTestCase {
|
||||
.where().istartsWith("name", "_U").findCount()
|
||||
).isEqualTo(1);
|
||||
|
||||
if (!isMySql()) {
|
||||
if (isPlatformCaseSensitive()) {
|
||||
assertThat(DB.find(Customer.class)
|
||||
.where().startsWith("shippingAddress.line1", "|p").findCount()
|
||||
).isEqualTo(0);
|
||||
|
||||
Reference in New Issue
Block a user