[odb-users] Problems with foreign key constraints when erasing

Troy Heron troy.heron at hixxy.org
Tue Dec 3 00:46:18 EST 2013

I am using the most recent package from the website:

ODB object-relational mapping (ORM) compiler for C++ 2.3.0

I have another question ;)

Initially I was planning on using the object's 'name' as the primary key,
but my application requires that this no be static (objects can be
renamed). It seems that this would not be possible with foreign key
constraints. So... I've changed all the objects to have a separate id field
as primary key and made the name a unique constraint instead. Now I'm
having troubles with using load() as at the time of loading an object, I
know the name, not the id. Of course, I could query for the object, but
that doesn't return a shared_ptr like load does.

Any idea what the best way to deal with this situation is? I need a primary
key that can change without breaking foreign key constraints or to be able
to load using a field other than the primary key.

I may have missed something in the docs (which are great btw)... any help


On Mon, Dec 2, 2013 at 8:43 PM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi Troy,
> Troy Heron <troy.heron at hixxy.org> writes:
> > Is there much involved in the implementation or is it mostly a matter
> > of turning it on?
> All the underlying machinery is already there (we use ON DELETE CASCADE
> internally to implement containers). So it is a matter of adding the
> pragmas, diagnosing all the corner cases, adding a test, and writing
> the documentation. In fact, I've done the first three this morning.
> Can you let me know which ODB compiler package you are using?
> Boris

More information about the odb-users mailing list