Fixed
Status Update
Comments
da...@google.com <da...@google.com>
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 10279986f24d1648952e740ea38c72b7bc44fdc7
Author: Elif Bilgin <elifbilgin@google.com>
Date: Tue Oct 26 16:59:42 2021
Resolving auto migration issue where SQLite keywords are failed to be escaped in column names.
The issue was arising from the part of AutoMigrationWriter generating code to transfer data from the old table to the new table, preserving the order of the columns. The SQL statement used did not utilize `` to escape the column names, resulting in a compiler error in scenarios where a SQLite keyword was being used as a column name.
Issue was repro'd in the tests by using the column name "index" and confirming the escape is working as expected with the new changes.
Test: AutoMigrationTest.java
Bug: 197133152
Change-Id: Idbed488acb2027fb1c0d9c302d1cc83ed5bfba2c
M room/room-compiler/src/main/kotlin/androidx/room/writer/AutoMigrationWriter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/AutoMigrationDb.java
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.AutoMigrationDb/1.json
https://android-review.googlesource.com/1870037
Branch: androidx-main
commit 10279986f24d1648952e740ea38c72b7bc44fdc7
Author: Elif Bilgin <elifbilgin@google.com>
Date: Tue Oct 26 16:59:42 2021
Resolving auto migration issue where SQLite keywords are failed to be escaped in column names.
The issue was arising from the part of AutoMigrationWriter generating code to transfer data from the old table to the new table, preserving the order of the columns. The SQL statement used did not utilize `` to escape the column names, resulting in a compiler error in scenarios where a SQLite keyword was being used as a column name.
Issue was repro'd in the tests by using the column name "index" and confirming the escape is working as expected with the new changes.
Test: AutoMigrationTest.java
Bug: 197133152
Change-Id: Idbed488acb2027fb1c0d9c302d1cc83ed5bfba2c
M room/room-compiler/src/main/kotlin/androidx/room/writer/AutoMigrationWriter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/AutoMigrationDb.java
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.AutoMigrationDb/1.json
Description
Component
Description
Adding column name with SQL keyword makes the compiler fail to escape the keyword and thereafter fail to migrate the database.
I seem to be unable to escape this even with the
RenameColumn
andDeleteColumn
as they seek the exact names and therefore will skip escaping with `.Proposed Solution
Have the compiler escape SQL keywords in column and table names.
Code sample
Before:
After: