MySQL: Declare VARCHAR columns as BINARY In MySQL a VARCHAR column that is a member of a table's primary key will be treated as case-insensitive, that is "BOB" and "bob" are identical and cannot both appear in the table. This does not match with the other implementations that gwtorm supports, in both H2 and PostgreSQL these are distinct rows, and Gerrit Code Review relies on this to support projects like the Linux kernel where files may appear in the same directory and differ only by case. Declare all MySQL varchar columns as binary to ensure the server uses case-sensitive sorting and compare rules. Change-Id: Idebf6994f71c3a054d003b8061abaff48c113ed5 Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/pom.xml b/pom.xml index f19f4e6..6eae2e4 100644 --- a/pom.xml +++ b/pom.xml
@@ -21,7 +21,7 @@ <groupId>gwtorm</groupId> <artifactId>gwtorm</artifactId> <packaging>jar</packaging> - <version>1.1.6</version> + <version>1.1.7</version> <name>gwtorm</name> <description>Tiny ORM</description> <url>http://android.git.kernel.org/?p=tools/gwtorm.git</url>
diff --git a/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java b/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java index f81ad33..fed1c61 100644 --- a/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java +++ b/src/main/java/com/google/gwtorm/schema/sql/DialectMySQL.java
@@ -41,12 +41,12 @@ final int type; if (column.length() <= 0) { - r.append("VARCHAR(255)"); + r.append("VARCHAR(255) BINARY"); if (col.isNotNull()) { r.append(" DEFAULT ''"); } } else if (column.length() <= 255) { - r.append("VARCHAR(" + column.length() + ")"); + r.append("VARCHAR(" + column.length() + ") BINARY"); if (col.isNotNull()) { r.append(" DEFAULT ''"); }