[BangPypers] SQLAlchemy and 'non-trivial' default values for a column
Sriram Karra
karra.etc at gmail.com
Wed Feb 20 08:15:52 CET 2013
On Mon, Feb 18, 2013 at 2:29 PM, Kiran Jonnalagadda <jace at pobox.com> wrote:
>
> The trick is to override __init__ and set the value of the column to an
> SQL expression that is evaluated database-side on commit. In my case, I'm
> checking for the max value from existing instances that share the same
> parent. In your case, it'll be instances that share the same date.
>
I try to keep my code free of any SQL expressions - in equal measure out a
real lack of understanding SQL subtleties and to keep the code 'pure'
ORM-ish. But this is definitely interesting and something I could try next
time I need it.
More information about the BangPypers
mailing list