Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
Actually that was an experimental API we thought about removing a couple of times but decided to keep for now.
About 1-1, it is actually better to write them as join queries. Is there a case where join is not feasible?
About 1-1, it is actually better to write them as join queries. Is there a case where join is not feasible?
t....@gmail.com <t....@gmail.com> #3
The issue with a JOIN is not feasibility. I suspect that can be done, albeit at the cost of yet another non-entity POJO.
Let's flip it around: given your characterization of the origins of @Relation ("an experimental API") and its possible lame-duck status ("decided to keep for now"), should we be using it?
Let's flip it around: given your characterization of the origins of @Relation ("an experimental API") and its possible lame-duck status ("decided to keep for now"), should we be using it?
bu...@gmail.com <bu...@gmail.com> #4
How would I load all the relation objects immediately without a relation? I see in your documentation that you have a query like "@Query("SELECT user.name AS userName, pet.name AS petName "
+ "FROM user, pet "
+ "WHEREuser.id = pet.user_id")
public LiveData<List<UserPet>> loadUserAndPetNames();", but how would you load complete objects with it, not just certain fields? I tried using something like "SELECT * , * as comments FROM users, comments", but it was throwing an error?
+ "FROM user, pet "
+ "WHERE
public LiveData<List<UserPet>> loadUserAndPetNames();", but how would you load complete objects with it, not just certain fields? I tried using something like "SELECT * , * as comments FROM users, comments", but it was throwing an error?
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com> #5
I'm interested in this feature along with the ability to use a projection like "[expression] AS [column-name]" and map to a single value. Additionally, since the @Relation annotation is never mentioned on the Room page, will it be maintained?
si...@gmail.com <si...@gmail.com> #6
It will be maintained, and added to the Room page.
yb...@google.com <yb...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit c5dad6522e6c20bbd5ca8e53b8406a94cb84cfe8
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jun 12 16:43:53 2019
Allow single-value @Relation field.
This change lifts the restriction of @Relation annotated fields needing
to be List or Set allowing for a more seamless representation of a
one-to-one relationship.
Changes in the generated code is so that it is not always assumed that
the relation field is a collection, thus not needing a temporary
collection when collecting the relating objects.
Bug: 62905145
Test: ./gradlew room:room-compiler:test \
room:integration-tests:room-testapp:cC
Change-Id: I462d59e89b55c43842df43cb84c1aeca0b2b743e
M room/common/src/main/java/androidx/room/Relation.java
M room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/main/kotlin/androidx/room/writer/RelationCollectorMethodWriter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PetDao.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PojoWithRelationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/PetAndOwner.java
https://android-review.googlesource.com/982373
https://goto.google.com/android-sha1/c5dad6522e6c20bbd5ca8e53b8406a94cb84cfe8
Branch: androidx-master-dev
commit c5dad6522e6c20bbd5ca8e53b8406a94cb84cfe8
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jun 12 16:43:53 2019
Allow single-value @Relation field.
This change lifts the restriction of @Relation annotated fields needing
to be List or Set allowing for a more seamless representation of a
one-to-one relationship.
Changes in the generated code is so that it is not always assumed that
the relation field is a collection, thus not needing a temporary
collection when collecting the relating objects.
Bug: 62905145
Test: ./gradlew room:room-compiler:test \
room:integration-tests:room-testapp:cC
Change-Id: I462d59e89b55c43842df43cb84c1aeca0b2b743e
M room/common/src/main/java/androidx/room/Relation.java
M room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/processor/ProcessorErrors.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/main/kotlin/androidx/room/writer/RelationCollectorMethodWriter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/dao/PetDao.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/PojoWithRelationTest.java
A room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/PetAndOwner.java
da...@google.com <da...@google.com> #8
I'd prefer if we just copy the implementation to avoid a Kotlin version dependency. Feel free to send us a PR in
ap...@google.com <ap...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 5746e3392b60a9f79bca2d7f93774cc5cf50383f
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Aug 24 04:31:51 2020
[GH] Fix upper/lowercase locale issues
## Proposed Changes
- Get rid of all `toUpperCase()`, `toLowerCase()`, `capitalize()` and `decapitalize()` calls inside Room without a `Locale` to avoid localization issues (specifically with Turkish).
## Testing
Test: Added one test that verifies this fix (similar to the issue mentioned in the ticket, test fails without my changes)
## Issues Fixed
Fixes: 68159494
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/70 .
Resolves #70
Github-Pr-Head-Sha: 937fcb76f264b10e7277025f74f4febebb899251
GitOrigin-RevId: 74697ccb895897266e374e40bfd5bd9bed370002
Change-Id: Ibea01d68d55be46db1a98655d69066409b463e99
M room/compiler/src/main/kotlin/androidx/room/ext/string_ext.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/CustomTypeConverterWrapper.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/PrimitiveColumnTypeAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/verifier/jdbc_ext.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Field.kt
M room/compiler/src/main/kotlin/androidx/room/vo/FtsOptions.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Warning.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/EntityCursorConverterWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/FieldReadWriteWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/FtsTableInfoValidationWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/TableInfoValidationWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/ViewInfoValidationWriter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
https://android-review.googlesource.com/1407967
Branch: androidx-master-dev
commit 5746e3392b60a9f79bca2d7f93774cc5cf50383f
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Aug 24 04:31:51 2020
[GH] Fix upper/lowercase locale issues
## Proposed Changes
- Get rid of all `toUpperCase()`, `toLowerCase()`, `capitalize()` and `decapitalize()` calls inside Room without a `Locale` to avoid localization issues (specifically with Turkish).
## Testing
Test: Added one test that verifies this fix (similar to the issue mentioned in the ticket, test fails without my changes)
## Issues Fixed
Fixes: 68159494
This is an imported pull request from
Resolves #70
Github-Pr-Head-Sha: 937fcb76f264b10e7277025f74f4febebb899251
GitOrigin-RevId: 74697ccb895897266e374e40bfd5bd9bed370002
Change-Id: Ibea01d68d55be46db1a98655d69066409b463e99
M room/compiler/src/main/kotlin/androidx/room/ext/string_ext.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/CustomTypeConverterWrapper.kt
M room/compiler/src/main/kotlin/androidx/room/solver/types/PrimitiveColumnTypeAdapter.kt
M room/compiler/src/main/kotlin/androidx/room/verifier/jdbc_ext.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Field.kt
M room/compiler/src/main/kotlin/androidx/room/vo/FtsOptions.kt
M room/compiler/src/main/kotlin/androidx/room/vo/RelationCollector.kt
M room/compiler/src/main/kotlin/androidx/room/vo/Warning.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/EntityCursorConverterWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/FieldReadWriteWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/FtsTableInfoValidationWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/TableInfoValidationWriter.kt
M room/compiler/src/main/kotlin/androidx/room/writer/ViewInfoValidationWriter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/FieldProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/writer/DaoWriterTest.kt
Description
Version used: 1.0.0-rc1
Devices/Android versions reproduced on: compile
These are my entity and dao classes.
----------------------------------------------------------------------------------------------------------
@Entity
public class Playlist {
@PrimaryKey(autoGenerate = true) private int id;
private String name;
private String path;
@ColumnInfo(name = "icon_path") private String iconPath;
private int type;
@ColumnInfo(name = "date_created") private long dateCreated;
@ColumnInfo(name = "date_last_opened") private long dateLastOpened;
public int getId() {
return id;
}
public void setId(int id) {
}
public String getName() {
return name;
}
public void setName(String name) {
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getIconPath() {
return iconPath;
}
public void setIconPath(String iconPath) {
this.iconPath = iconPath;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public long getDateCreated() {
return dateCreated;
}
public void setDateCreated(long dateCreated) {
this.dateCreated = dateCreated;
}
public long getDateLastOpened() {
return dateLastOpened;
}
public void setDateLastOpened(long dateLastOpened) {
this.dateLastOpened = dateLastOpened;
}
}
----------------------------------------------------------------------------------------------------------
@Dao
public interface PlaylistDao {
@Query("SELECT * FROM playlist")
List<Playlist> getAll();
@Insert
void insert(Playlist playlist);
@Delete
void delete(Playlist playlist);
}
----------------------------------------------------------------------------------------------------------
I'm getting compile time error that cannot find getter for id and iconPath field.
----------------------------------------------------------------------------------------------------------
Playlist.java:15: error: Cannot find getter for field.
@PrimaryKey(autoGenerate = true) private int id;
^
Playlist.java:18: error: Cannot find getter for field.
@ColumnInfo(name = "icon_path") private String iconPath;
^
----------------------------------------------------------------------------------------------------------
While I looked into generated PlaylistDao implementation class, i saw that 'İ' is used as uppercase of 'i'.
----------------------------------------------------------------------------------------------------------
public List<Playlist> getAll() {
final String _sql = "SELECT * FROM playlist";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
final Cursor _cursor = __db.query(_statement);
try {
final int _cursorIndexOfİd = _cursor.getColumnIndexOrThrow("id");
final int _cursorIndexOfName = _cursor.getColumnIndexOrThrow("name");
final int _cursorIndexOfPath = _cursor.getColumnIndexOrThrow("path");
final int _cursorIndexOfİconPath = _cursor.getColumnIndexOrThrow("icon_path");
final int _cursorIndexOfType = _cursor.getColumnIndexOrThrow("type");
final int _cursorIndexOfDateCreated = _cursor.getColumnIndexOrThrow("date_created");
final int _cursorIndexOfDateLastOpened = _cursor.getColumnIndexOrThrow("date_last_opened");
final List<Playlist> _result = new ArrayList<Playlist>(_cursor.getCount());
while(_cursor.moveToNext()) {
final Playlist _item;
_item = new Playlist();
_
final String _tmpName;
_tmpName = _cursor.getString(_cursorIndexOfName);
_item.setName(_tmpName);
final String _tmpPath;
_tmpPath = _cursor.getString(_cursorIndexOfPath);
_item.setPath(_tmpPath);
_item.iconPath = _cursor.getString(_cursorIndexOfİconPath);
final int _tmpType;
_tmpType = (int) _cursor.getInt(_cursorIndexOfType);
_item.setType(_tmpType);
final long _tmpDateCreated;
_tmpDateCreated = _cursor.getLong(_cursorIndexOfDateCreated);
_item.setDateCreated(_tmpDateCreated);
final long _tmpDateLastOpened;
_tmpDateLastOpened = _cursor.getLong(_cursorIndexOfDateLastOpened);
_item.setDateLastOpened(_tmpDateLastOpened);
_result.add(_item);
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
----------------------------------------------------------------------------------------------------------
I'm using Turkish keyboard. I tried changing my keyboard input as English and wrote entity class again. I also tried convert file encoding of playlist class but the problem was not solved.
It only compile without error when i change getters with getİd and getİconPath.