Thanks for clarifying that. The MapperExtension is what I've been using so far for this, just wondered if there was a way to do this with column-level defaults. Now that I think about it though, the current way probably does make more sense, since if the values are dependent on "outside influences", they cease to be "column-level defaults".
On Mar 5, 2:48 pm, "Michael Bayer" <[email protected]> wrote: > Oliver Beattie wrote: > > Sorry to bug I imagine there is no way of doing this, but would be > > good to know for sure. If not, this would be really useful > > functionality. For instance, I might want to populate one column based > > on the contents of one of more other columns. > > > On 12 Jan, 11:21, Oliver Beattie <[email protected]> wrote: > >> Hi there, > > >> I feel like I'm perhaps missing something, but I wonder if there's any > >> way to access the object being updated inside a ColumnDefault? More > >> specifically, if I have a let's call it DBObject (using declarative) > >> which has a callable as its default, is there any way to access that > >> DBObject instance inside the default function? I see it gets passed an > >> ExecutionContext instance, but I don't see a way to get the object > >> from there :\ > > >> If there's a way to do this, it would help me a lot :) > > The executioncontext has all the parameters for the whole statement, you > can use those. But the ORM object is not available at that level. You > might want to use MapperExtension.before_insert() if you need ORM-level > awareness. > > > > > > >> Thanks, > >> Oliver > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to [email protected]. > > 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. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
