[odb-users] any access to sequence without explicitly naming it?

NIkolai Marchenko enmarantispam at gmail.com
Sun Aug 31 01:52:26 EDT 2025


Note: the name of the initial message may be misleading and I may be in
need of an entirely different solution.

I have encountered a weird use case trying to use the new points_to
functionality that I am not sure how to deal with:

suppose an object contains another object. an inner objects points_to the
outer object with on delete cascade option and both are not persistent yet.
The objects both have auto id quint64 keys. Since they both don't have id
yet, I cannot assign an id to points_to and when I persist the _outer_
object it says that inner isn't persistent yet. but when I persist an
_inner_ object it also fails because foreign key constraint is not
satisfied. the schema is created with deferred constraint checking ... but
I they need to have matching ids beforehand.

The only way I see of breaking this loop is to access a sequence for the
outer object inisde the transaction and reserving the key to it that I can
feed into points_to... but as far as I can see odb doesn't have a native
function to access a sequence. This means I have to .execute("raw sql
here") and this is potentially breaking on refactors. Am I missing
something obvious on how to deal with those?


More information about the odb-users mailing list