DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

SQLiteException

Open OptimistNot opened this issue 11 years ago • 5 comments

Hey! Congrats for the new version! :) Im still trying to use JsonModel in my project... getting this: SQLiteException: near "product_audit_id": syntax error (code 1): , while compiling: SELECT * FROM ProductAudit WHERE product_audit_id=1 on load() of JsonModel. I have no clue what's going on. Please help me!

OptimistNot avatar Jun 02 '15 15:06 OptimistNot

I resolve issue with this shit:

String primary_key_query = FlowManager.getPrimaryWhereQuery( getTable()).getQuery().split("=")[0] + "=" + primaryKeys[0]; Cursor cursor = new Select() .from(mModelAdapter.getModelClass()) .where(primary_key_query).query();

Please resolve that!!!

amrsilva avatar Jun 03 '15 10:06 amrsilva

Whats the class look like? I could help you if you give me more information on the issue.

agrosner avatar Jun 11 '15 18:06 agrosner

I'm getting this error as well in the context of byIds() call.

carmelo-ruota also mentions this in here: https://github.com/Raizlabs/DBFlow/issues/275

It looks like getPrimaryWhereQuery or getPrimaryModelWhere is escaping the column name twice, and it is passed to the SQL engine in double tick-quotes like :

``id``

I have a base class with

@Column String id;
// and then do:
new Select().from(MyClass.class).byIds("123").querySingle()

battlmonstr avatar Jun 19 '15 09:06 battlmonstr

I believe this error occurs if there is no record with the given condition.

kayvannj avatar Jun 22 '15 21:06 kayvannj

byIds no longer exists, and queries have been improved in 3.0.0, so this wont happen anymore.

agrosner avatar Feb 29 '16 00:02 agrosner