Hello everybody,

I'm having hard time figuring out how or whether it is possible at all
to use select statement that can access record to be inserted as
column's default value.

groups = Table('groups', meta,
    Column('id', Integer, primary_key=True),
    Column('prefix', String(32), nullable=False, unique=True)
)

accounts = Table('accounts', meta,
    Column('number', String(32), primary_key=True),
    Column('group_id', Integer, ForeignKey('groups.id'),
nullable=False,
        default=select([groups.c.id], groups.c.prefix ==
somefunc(current_accounts_record)))
)

Basically, what I need is to be able to access record/values to be
inserted into accounts table to build correct select clause. I know
how to do that on ORM level using MapperExtension but I want to
enforce this on table level instead. And I realize that I can
explicitly call my function to assign value to group_id at the time
accounts.insert is executed but that doesn't smell good.

Any help is greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to