[odb-users] querying object and loading into a stack variable,
then setting its id to 0 and persisting
Boris Kolpackov
boris at codesynthesis.com
Mon Jul 22 00:52:00 EDT 2024
MM <finjulhich at gmail.com> writes:
> struct C {
> std::uint64_t id; #pragma member id auto
> ....
> };
>
> C myc;
> db.query_one<future>(..., myc);
> /// successful
> myc.setid(0);
> myc.changeotherattributes();
>
> db.persist(myc);
>
> /// this seems to INSERT a new object with value 0 for id, but my intention
> is to clone the loaded object myc, change attributes, and let the database
> determine the new id.
Provided the C::id member is auto-assigned, this should do what you expect
so I suspect there is something wrong with your setup. If you think this is
a bug in ODB, please provide a complete reproducer and also specify which
database we are talking about. In fact, ALWAYS specify which database we
are talking about.
> does odb keep track of the object memory addresses for determining whether
> to UPDATE vs INSERT?
No, ODB doesn't do anything like this.
More information about the odb-users
mailing list