[odb-users] Unable to use odb::nullable<unsigned long long> on id table

Boris Kolpackov boris at codesynthesis.com
Wed Jul 20 13:15:08 EDT 2016


Hi Mickaël,

Mickaël Girard <mgirard at theleme.com> writes:

> In my database, I have a table with Id (the Primary key) that is created
> with a trigger. When inserting, if id is null, id is get from a table
> sequence.

You probably already know this: ODB can do all of this without the
trigger if you mark the id as 'auto'.


> #pragma db column("ID") id
> odb::nullable<unsigned long long> m_adresse_mail_id;
> 
> and I have the following compiling error :
> 
> error: value type that is used as object id in persistent class with session
> support does not define the less than (<) comparison

I think you are the first person trying to use nullable for an id
data member and you've uncovered a bug that doesn't really have
anything to do with the problem in question. I've fixed it and
here is the patch:

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

While I think the basic functionality that you are looking for
will now work (i.e., you will be able to pass NULL to the database),
there is a big problem with this approach: the id that is assigned
by the database won't be returned to the caller and won't be stored
in the object. This is the advantage of the 'auto' approach I've
mentioned above: it takes care of all of this.

Boris



More information about the odb-users mailing list