[odb-users] question: persist operation for sqlite binding

Boris Kolpackov boris at codesynthesis.com
Mon Apr 10 12:35:18 EDT 2017


Hi Takehiro,

takehiro iyatomi <iyatomi at gmail.com> writes:

> hi, thank you for creating odb. that saves my life a lot :D

Thanks, glad to hear that!


> suppose I define object that have id_ column as #pragma db id auto
> and set id_ to non-zero value before persist it into sqlite database.
> whatever value is set to id_ , sqlite silently ignored that value and
> returns auto-incremented id_ value as a result.
>
> [...]
> 
> this is expected behavior? if so, should I expect same behavior for other
> database binding like mysql?

Yes, the semantics of automatically assigned object id is that the
database, not you, assigns it (and guarantees that it will not
conflict with any existing object id). This consistent across
all the supported databases.

Having said that, for SQLite and MySQL we have added this extra
functionality (will be available in 2.5.0):

http://scm.codesynthesis.com/?p=odb/odb.git;a=commit;h=4fd2c107242fe9f8e6ba7ded2a789f4de2ccd040

http://scm.codesynthesis.com/?p=odb/odb.git;a=commit;h=fc65c4e978759fa10fc61341d98d4dccac42a53f

Boris



More information about the odb-users mailing list