Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
*Room, not Realm haha
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com> #3
i'm still skeptical about changing the default to crash because I'm worried that some apps won't handle migrating from older versions properly.
But creating a builder option totally makes sense so that more avare developers can turn it on.
Btw, another nice thing about drop by default is the development time. during development, you can easily increment it and pass the check and then just provide the migration from latest release to current release when shipping the app.
But creating a builder option totally makes sense so that more avare developers can turn it on.
Btw, another nice thing about drop by default is the development time. during development, you can easily increment it and pass the check and then just provide the migration from latest release to current release when shipping the app.
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