Take the 2-minute tour ×  I have a small problem that I think
should be easily handled by SQL Alchemy but I can't seem to get
it right. I have two tables with one being a parent table and
the other a child table. For each child record it needs a unique
ID but only with the context of the unique parent record.  I am
using the Declarative Base approach.  I setup the parent child
relationship using the FKs and the relation function. What I'm
trying to achieve is to get something like a pseudo
autoincrement function that will lookup the max CategoryID value
within the Category unique name group and increment it up one.
I've tried using various default functions but the problem I run
into is the inability to specify the CategoryUniqueName at the
time of insertion. I can't find a way to pass the current value
of CategoryItems.CategoryUniqueName so that the lookup query has
the correct filter applied when trying to select something like
func.max(CategoryItems.CategoryID). If I hardcode a query it
works just fine. Th