DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Quote table and columns for update()

Open andrecrispim opened this issue 11 years ago • 7 comments

I think you should quote table and columns for update():

Error while trying to update a table named Order: near "Order": syntax error (code 1): , while compiling: UPDATE OR ABORT Order SET LocationId=?,DateUpdate=?,Date=?,StatusId=?,OrderId=?,EventId=?,DateInsert=? WHERE OrderId=1

andrecrispim avatar May 21 '15 16:05 andrecrispim

Which update() method you're using? One of them does not quote its columns because of the ContentProvider. Can't remember which one.

agrosner avatar Jun 01 '15 19:06 agrosner

BaseModel.update()

andrecrispim avatar Jun 03 '15 13:06 andrecrispim

Trying to save(through setter/constructor) a foreign key which is model causes following problem , in: model$adapter > bindToStatement (sqlstatment,model) >
................................................................................ // Begin Saving Foreign Key References From Model if (model.transaction != null) { model.transaction.save();

Calling save() generates : near "Transaction": syntax error (code 1): , while compiling: UPDATE OR ABORT Transaction SET companyID=?,timestamp=?,amount=?,categoryID=?,description=?,type=?,id=? WHERE id=2

Any way to avoid this ?

Dokuzov avatar Jul 08 '15 08:07 Dokuzov

You can use the new Update<>(), like:

        new Update<>(Order.class).set(
                Condition.column(Order$Table.LOCATION_LOCATIONID).is(order.getLocationId()),
                Condition.column(Order$Table.EVENT_EVENTID).is(order.getEventId()),     
                Condition.column(Order$Table.STATUS_STATUSID).is(order.getStatusId()),
                .where(Condition.column(Order$Table.ORDERID).is(order.getId()))
                .query();

andrecrispim avatar Jul 08 '15 19:07 andrecrispim

That's exactly what i am doing, thanks for the suggestion.However using queries like this makes you unable to use the FlowContentObserver .

Dokuzov avatar Jul 09 '15 06:07 Dokuzov

Im going to see if I can solve this during the rewrite of the annotation processor in 3.0.0 and find a safe way to do this.

agrosner avatar Aug 21 '15 01:08 agrosner

fixed it.

agrosner avatar Nov 25 '15 02:11 agrosner