diff --git a/src/main/java/io/ebean/config/dbplatform/sqlserver/SqlServerBasePlatform.java b/src/main/java/io/ebean/config/dbplatform/sqlserver/SqlServerBasePlatform.java index 75591f2ad..960309bbc 100644 --- a/src/main/java/io/ebean/config/dbplatform/sqlserver/SqlServerBasePlatform.java +++ b/src/main/java/io/ebean/config/dbplatform/sqlserver/SqlServerBasePlatform.java @@ -47,8 +47,8 @@ abstract class SqlServerBasePlatform extends DatabasePlatform { this.openQuote = "["; this.closeQuote = "]"; this.likeSpecialCharacters = new char[]{'%', '_', '['}; - this.likeClauseRaw = "like ? collate Latin1_General_BIN"; - this.likeClauseEscaped = "like ? collate Latin1_General_BIN"; + this.likeClauseRaw = "like ?"; + this.likeClauseEscaped = "like ?"; booleanDbType = Types.INTEGER; this.dbDefaultValue.setFalse("0"); diff --git a/src/test/java/io/ebean/BaseTestCase.java b/src/test/java/io/ebean/BaseTestCase.java index ee10521e9..db22d6deb 100644 --- a/src/test/java/io/ebean/BaseTestCase.java +++ b/src/test/java/io/ebean/BaseTestCase.java @@ -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. diff --git a/src/test/java/org/tests/query/TestQueryFilterCaseInsensitive.java b/src/test/java/org/tests/query/TestQueryFilterCaseInsensitive.java index 8e565c571..86a71b324 100644 --- a/src/test/java/org/tests/query/TestQueryFilterCaseInsensitive.java +++ b/src/test/java/org/tests/query/TestQueryFilterCaseInsensitive.java @@ -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 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 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 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 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 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 diff --git a/src/test/java/org/tests/query/other/TestLikeEscaping.java b/src/test/java/org/tests/query/other/TestLikeEscaping.java index ceebbcddc..d5eb0e92c 100644 --- a/src/test/java/org/tests/query/other/TestLikeEscaping.java +++ b/src/test/java/org/tests/query/other/TestLikeEscaping.java @@ -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);