On May 22, 2008, at 4:44 PM, askel wrote:
> > I implemented it the way Michael suggested. Now, I'm wondering if it > can be done as a subquery, i.e. avoiding pre-execution of select > clause. May be that is pretty much SQL engine specific but so are > sequences and foreign keys. Resulting query built by compiler should > be like the following: > > INSERT INTO accounts (group_id, number) VALUES ((SELECT id FROM groups > WHERE prefix=:prefix), :number) > > prefix and number are bind parameters. number came from > accounts.insert() and prefix is produced by column default function > based on number parameter. yeah, the plumbing doesn't connect exactly that way at the moment, as far as a Column-level default is concerned. The parameters used for execution are not available at insert() compile time, that was a coupling we broke off in 0.4 which greatly simplified things. I think you already know you can do it at the ORM level though by setting the object's attribute to a SQL expression, then flushing - the mapper embeds the expression inline. You could set that up in the __init__ method of your class to make it a "default". --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---