DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Creating table Order with Foreign Key not possible

Open gnuhel opened this issue 11 years ago • 0 comments

I want to create a table called Order with a foreign key like this

@Column(columnType = Column.FOREIGN_KEY, references = {@ForeignKeyReference(columnName = "orderId", columnType = Integer.class, foreignColumnName = "id")}) public Order order;

But I get the error when I try to create the table

Caused by: android.database.sqlite.SQLiteException: near "Order": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTSOrderItem(idINTEGER PRIMARY KEY AUTOINCREMENT,orderIdINTEGER DEFAULT 0,productItemIdINTEGER DEFAULT 0,nameTEXT,sortOrderINTEGER DEFAULT 0, FOREIGN KEY(orderId) REFERENCES Order (id) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(productItemId) REFERENCES ProductItem (id) ON UPDATE NO ACTION ON DELETE NO ACTION );

It seems that order is a reserved keywords.

gnuhel avatar Apr 02 '15 12:04 gnuhel