chennaione / sugar

Insanely easy way to work with Android Database.
http://satyan.github.com/sugar/
MIT License
2.62k stars 583 forks source link

SQLITE KEYWORDS #98

Open zkavtaskin opened 10 years ago

zkavtaskin commented 10 years ago

05-20 17:24:51.757: E/AndroidRuntime(1655): java.lang.RuntimeException: Unable to start activity android.database.sqlite.SQLiteException: near "EXISTS": syntax error (code 1): , while compiling: CREATE TABLE SOMETHING ( ID INTEGER PRIMARY KEY AUTOINCREMENT , DATE_CREATED INTEGER, OTHER TEXT, EXISTS INTEGER, SYNCED INTEGER, OTHER2 TEXT, STUFF INTEGER, COUNTER INTEGER )

Please update query generator to take in to account SQLite Keywords. http://www.sqlite.org/lang_keywords.html

I.e.

CREATE TABLE SOMETHING ( [ID] INTEGER PRIMARY KEY AUTOINCREMENT , [DATE_CREATED] INTEGER, [OTHER] TEXT, [EXISTS] INTEGER, [SYNCED] INTEGER, [OTHER2] TEXT, [STUFF] INTEGER, [COUNTER] INTEGER )

PepeuCps commented 10 years ago

I think it isnt recommendable to use reserved words. Am I wrong?

zkavtaskin commented 10 years ago

Infrastructure (ORM i.e. Persistence) should not dictate to the business logic / domain layer how it should name it's entities or properties. Infrastructure is the servant not other way round. Besides the fix for this is really simple and all popular ORM frameworks do it i.e. Hibernate, Entity Framework, etc.

Edit: I am not even going to mention security, command conflicts and versioning.

satyan commented 10 years ago

I tend to agree with @zkavtaskin here. The framework should not be a limiting factor. Though, practically, we tend to stay away from reserved keywords to avoid any issues later. We should however have that fix in place.. thanks for pointing that out.