Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
Thanks for the report. I will route this to the appropriate internal team and update this when I hear back from them.
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com> #3
One more detail, Data Layer event calls from the watch to the phone (running Android 13) do work on if the listener is in an Activity or Fragment.
Description
Version used: 1.0
Devices/Android versions reproduced on: all
I wasn't paying attention that I had a column name called "to" which is a SQL reserved keyword, but there was no problem at first and tables were created successfully and there was no problem until I decided to use @Relation to automatically fetch relation entities.
@Entity(tableName = "categories")
public class Category {
@PrimaryKey(autoGenerate = true)
public long id;
public String name;
}
@Entity(tableName = "topics", foreignKeys = @ForeignKey(entity = Category.class,
parentColumns = "id",
childColumns = "category_id",
onDelete = ForeignKey.CASCADE))
public class Topic {
@PrimaryKey(autoGenerate = true)
public long id;
@ColumnInfo(name = "category_id")
public long categoryId;
public String to;
}
public class CategoryWithTopics {
@Embedded
public Category category;
@Relation(parentColumn = "id", entityColumn = "category_id", entity = Topic.class)
public List<Topic> topics;
}
and in the DAO
@Transaction
@Query("SELECT * FROM categories")
List<CategoryWithTopics> getPerDiemDraftsWithItems();
This produces a compile time error "Error:(17, 24) error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (near "to": syntax error)"
It was a stupid mistake to name the column one of the SQL reserved keywords, but it was working without any problems when it's escaped when creating the table but looks like the query changed when using the Relation annotation and the reserved keywords won't work there.
It may be not solvable, but at least we can have a small lint check for column names to be non-reserved SQL keyword.
A project where this can be reproduced is attached