[odb-users] querying object and loading into a stack variable, then setting its id to 0 and persisting

MM finjulhich at gmail.com
Sun Jul 21 15:58:28 EDT 2024


Hi,

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.

do I just get a copy of myc then work on that instead?

does odb keep track of the object memory addresses for determining whether
to UPDATE vs INSERT?

confused,


More information about the odb-users mailing list