Fixed
Status Update
Comments
se...@google.com <se...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
ya...@google.com <ya...@google.com> #3
ya...@google.com <ya...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically ( b/140759491 ).
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
https://android-review.googlesource.com/1288456
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
yb...@google.com <yb...@google.com> #5
I think they are 2 different things.
A part of this is allowing people to set default values on columns such that it will translate into sqlite. They may simply be relying on it for @Query methods that do insert (which we do not support yet but we can, we should).
Another task is allowing people to use @Insert / @Update to insert into tables that are different from the passed in pojo.
For that, we probably need to enforce the primary key set on the `UserSummary` but for `Insert` we can let them not have it as long as there is an autogenerate primary key.
A part of this is allowing people to set default values on columns such that it will translate into sqlite. They may simply be relying on it for @Query methods that do insert (which we do not support yet but we can, we should).
Another task is allowing people to use @Insert / @Update to insert into tables that are different from the passed in pojo.
For that, we probably need to enforce the primary key set on the `UserSummary` but for `Insert` we can let them not have it as long as there is an autogenerate primary key.
ya...@google.com <ya...@google.com> #6
I filed partial @Insert/@Update separately as b/127549506 .
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 4f917f20e63afc653a6092ad87cfbb10bcc1552c
Author: Yuichi Araki <yaraki@google.com>
Date: Tue Nov 13 17:19:00 2018
Support column default value
Adds a new method @ColumnInfo#defaultValue() to allow declaring the
schema default value of a column. The method allows for SQL literal
values and expressions. Room will also interpret the default value as
a string literal (surrounding it with single quotess) when the affinity
of the column in TEXT.
Bug: 64088772
Test: FieldProcessorTest, DefaultValueTest
Change-Id: I4219eaec34deae618c1b119287fd949a18315936
M room/common/api/2.2.0-alpha01.ignore
M room/common/api/2.2.0-alpha01.txt
M room/common/api/current.txt
M room/common/src/main/java/androidx/room/ColumnInfo.java
M room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/verifier/DatabaseVerifier.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Field.kt
M room/compiler/src/main/kotlin/androidx/room/writer/TableInfoValidationWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/ValidationWriter.kt
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
M room/integration-tests/incremental-annotation-processing/build.gradle
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/9.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/JournalDbPostMigrationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DefaultValueTest.java
M room/migration/api/restricted_2.2.0-alpha01.txt
M room/migration/api/restricted_current.txt
M room/migration/src/main/java/androidx/room/migration/bundle/FieldBundle.java
M room/migration/src/test/java/androidx/room/migration/bundle/DatabaseBundleTest.java
M room/migration/src/test/java/androidx/room/migration/bundle/EntityBundleTest.java
M room/migration/src/test/java/androidx/room/migration/bundle/FieldBundleTest.java
M room/runtime/api/restricted_2.2.0-alpha01.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
M room/runtime/src/main/java/androidx/room/util/TableInfo.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
https://android-review.googlesource.com/825803
https://goto.google.com/android-sha1/4f917f20e63afc653a6092ad87cfbb10bcc1552c
Branch: androidx-master-dev
commit 4f917f20e63afc653a6092ad87cfbb10bcc1552c
Author: Yuichi Araki <yaraki@google.com>
Date: Tue Nov 13 17:19:00 2018
Support column default value
Adds a new method @ColumnInfo#defaultValue() to allow declaring the
schema default value of a column. The method allows for SQL literal
values and expressions. Room will also interpret the default value as
a string literal (surrounding it with single quotess) when the affinity
of the column in TEXT.
Bug: 64088772
Test: FieldProcessorTest, DefaultValueTest
Change-Id: I4219eaec34deae618c1b119287fd949a18315936
M room/common/api/2.2.0-alpha01.ignore
M room/common/api/2.2.0-alpha01.txt
M room/common/api/current.txt
M room/common/src/main/java/androidx/room/ColumnInfo.java
M room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/verifier/DatabaseVerifier.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Field.kt
M room/compiler/src/main/kotlin/androidx/room/writer/TableInfoValidationWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/ValidationWriter.kt
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/verifier/DatabaseVerifierTest.kt
M room/integration-tests/incremental-annotation-processing/build.gradle
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/9.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/JournalDbPostMigrationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DefaultValueTest.java
M room/migration/api/restricted_2.2.0-alpha01.txt
M room/migration/api/restricted_current.txt
M room/migration/src/main/java/androidx/room/migration/bundle/FieldBundle.java
M room/migration/src/test/java/androidx/room/migration/bundle/DatabaseBundleTest.java
M room/migration/src/test/java/androidx/room/migration/bundle/EntityBundleTest.java
M room/migration/src/test/java/androidx/room/migration/bundle/FieldBundleTest.java
M room/runtime/api/restricted_2.2.0-alpha01.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
M room/runtime/src/main/java/androidx/room/util/TableInfo.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
da...@google.com <da...@google.com>
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 9ad96403444f1f199af41946e6548c5cfc834ce1
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jun 26 13:55:46 2019
Conditionally use column default value in equality check.
Based on the constructor called, which can be used to distinguish
between old generated code vs new generated code, don't take into
consideration column default value in equality check. This makes it
so that compatibility is maintained with old generated code using new
runtime that haven't had the chance to migrate their unaccounted for
default value migrations.
Bug: 64088772
Test: Manual - App with Room 2.1.0 & WM 1.0.0-alpha11, then upgarde both
Room to 2.2.0-alpha01 and WM to 1.0.0. Forcing WM to run migration
with new runtime, observed no crash.
Change-Id: I6649c05d39dee2e7a03e46ff01310042ac2a61f2
M room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
M room/runtime/src/main/java/androidx/room/util/TableInfo.java
https://android-review.googlesource.com/999815
https://goto.google.com/android-sha1/9ad96403444f1f199af41946e6548c5cfc834ce1
Branch: androidx-master-dev
commit 9ad96403444f1f199af41946e6548c5cfc834ce1
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jun 26 13:55:46 2019
Conditionally use column default value in equality check.
Based on the constructor called, which can be used to distinguish
between old generated code vs new generated code, don't take into
consideration column default value in equality check. This makes it
so that compatibility is maintained with old generated code using new
runtime that haven't had the chance to migrate their unaccounted for
default value migrations.
Bug: 64088772
Test: Manual - App with Room 2.1.0 & WM 1.0.0-alpha11, then upgarde both
Room to 2.2.0-alpha01 and WM to 1.0.0. Forcing WM to run migration
with new runtime, observed no crash.
Change-Id: I6649c05d39dee2e7a03e46ff01310042ac2a61f2
M room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
M room/runtime/src/main/java/androidx/room/util/TableInfo.java
ap...@google.com <ap...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 23e7e21de3f2438aa6d8676c371f2db8bd444495
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Mon Jul 08 13:09:30 2019
Conditionally use column default value in equality check part 2.
Instead of using constructor to determine if default value should be
ignored on equality check, simply ignore it if the table info has
a null default value. In practice, this means don't validate database
read default values (those read using PRAGMA table_info) if the
generated code (and the entity class) does not define a default value.
This eases migration to Room 2.2.0 for those apps who had accidentally
added default values with migrations using 'ALTER TABLE x ADD COLUMN y
TEXT NOT NULL DEFAULT z'. It won't cause their incremental migration
test to suddenly start failing and it won't cause a runtime validation
crash with 2.2.0 generated code for users whose database was migrated vs
those who recently had a fresh install. Similarly for library users of
Room such as WorkManager, their generated code using the old constructor
will still create table info objects whose default value are null,
causing them to not be validated because they weren't originally defined
in the entity.
There is also little to no value in prohibiting a default value in the
schema that is not define in Room's entity. However, if a default value
is defined in the entity class, then Room will validate its presence and
content.
Bug: 64088772
Bug: 136019383
Test: MigrationTest & TableInfoTest
Change-Id: I1f3f34a2139b2505a2bf73b88f917252496df930
M room/compiler/src/main/kotlin/androidx/room/writer/TableInfoValidationWriter.kt
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/10.json
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/11.json
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/9.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
M room/runtime/api/restricted_2.2.0-alpha02.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
M room/runtime/src/main/java/androidx/room/util/TableInfo.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
https://android-review.googlesource.com/1010368
https://goto.google.com/android-sha1/23e7e21de3f2438aa6d8676c371f2db8bd444495
Branch: androidx-master-dev
commit 23e7e21de3f2438aa6d8676c371f2db8bd444495
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Mon Jul 08 13:09:30 2019
Conditionally use column default value in equality check part 2.
Instead of using constructor to determine if default value should be
ignored on equality check, simply ignore it if the table info has
a null default value. In practice, this means don't validate database
read default values (those read using PRAGMA table_info) if the
generated code (and the entity class) does not define a default value.
This eases migration to Room 2.2.0 for those apps who had accidentally
added default values with migrations using 'ALTER TABLE x ADD COLUMN y
TEXT NOT NULL DEFAULT z'. It won't cause their incremental migration
test to suddenly start failing and it won't cause a runtime validation
crash with 2.2.0 generated code for users whose database was migrated vs
those who recently had a fresh install. Similarly for library users of
Room such as WorkManager, their generated code using the old constructor
will still create table info objects whose default value are null,
causing them to not be validated because they weren't originally defined
in the entity.
There is also little to no value in prohibiting a default value in the
schema that is not define in Room's entity. However, if a default value
is defined in the entity class, then Room will validate its presence and
content.
Bug: 64088772
Bug: 136019383
Test: MigrationTest & TableInfoTest
Change-Id: I1f3f34a2139b2505a2bf73b88f917252496df930
M room/compiler/src/main/kotlin/androidx/room/writer/TableInfoValidationWriter.kt
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/10.json
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/11.json
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.MigrationDb/9.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
M room/runtime/api/restricted_2.2.0-alpha02.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/androidTest/java/androidx/room/migration/TableInfoTest.java
M room/runtime/src/main/java/androidx/room/util/TableInfo.java
M room/testing/src/main/java/androidx/room/testing/MigrationTestHelper.java
Description
Version used:
Devices/Android versions reproduced on:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).