Make column type checks case-insensitive
Bug: 62875382
Test: TableInfoTest
Change-Id: Id98eae152b24e7e2ac5c622db2e819b248dd6322
diff --git a/room/runtime/src/androidTest/java/android/arch/persistence/room/migration/TableInfoTest.java b/room/runtime/src/androidTest/java/android/arch/persistence/room/migration/TableInfoTest.java
index d59d9a2..76effde 100644
--- a/room/runtime/src/androidTest/java/android/arch/persistence/room/migration/TableInfoTest.java
+++ b/room/runtime/src/androidTest/java/android/arch/persistence/room/migration/TableInfoTest.java
@@ -24,14 +24,13 @@
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-
import android.arch.persistence.db.SupportSQLiteDatabase;
import android.arch.persistence.db.SupportSQLiteOpenHelper;
import android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory;
import android.arch.persistence.room.util.TableInfo;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Test;
@@ -169,6 +168,17 @@
assertThat(info.foreignKeys.iterator().next(), is(expected));
}
+ @Test
+ public void caseInsensitiveTypeName() {
+ mDb = createDatabase(
+ "CREATE TABLE foo (n integer)");
+ TableInfo info = TableInfo.read(mDb, "foo");
+ assertThat(info, is(new TableInfo(
+ "foo",
+ toMap(new TableInfo.Column("n", "INTEGER", 0)),
+ Collections.<TableInfo.ForeignKey>emptySet())));
+ }
+
private static Map<String, TableInfo.Column> toMap(TableInfo.Column... columns) {
Map<String, TableInfo.Column> result = new HashMap<>();
for (TableInfo.Column column : columns) {
diff --git a/room/runtime/src/main/java/android/arch/persistence/room/util/TableInfo.java b/room/runtime/src/main/java/android/arch/persistence/room/util/TableInfo.java
index a1f6df2..c9d2021 100644
--- a/room/runtime/src/main/java/android/arch/persistence/room/util/TableInfo.java
+++ b/room/runtime/src/main/java/android/arch/persistence/room/util/TableInfo.java
@@ -244,7 +244,7 @@
//noinspection SimplifiableIfStatement
if (!name.equals(column.name)) return false;
- return type != null ? type.equals(column.type) : column.type == null;
+ return type != null ? type.equalsIgnoreCase(column.type) : column.type == null;
}
/**