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

takehiro iyatomi iyatomi at gmail.com
Mon Apr 10 03:51:06 EDT 2017


hi, thank you for creating odb. that saves my life a lot :D
I use odb compiler with following version on linux
=================
# odb --version
ODB object-relational mapping (ORM) compiler for C++ 2.4.0
Copyright (c) 2009-2015 Code Synthesis Tools CC
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=================

and have encounter strange problem. when I try to persist object into
sqlite database, it does not seem to respect value of database id column.

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.

I found generated code do something like following:
===========================

if (init (im, obj, statement_insert))

      im.version++;

    im.id_null = true;
===========================

seems set true to id_null, no matter what set by init. if I change
[im.id_null = true] to [im.id_null = obj.id_ == 0], problem solved.

this is expected behavior? if so, should I expect same behavior for other
database binding like mysql?

regards,

Takehiro Iyatomi


More information about the odb-users mailing list