Thanks! I used @validate and it worked well for what I needed. On Tuesday, November 6, 2012 3:23:47 PM UTC-3, John Anderson wrote: > > I update certain columns with default=foo and want that same 'foo' > function to run onupdate as well, but sometimes an update will be ran only > updating a single column in which case the context I need isn't in > context.current_parameters, so then I can't do anything and the value is > set to None since I don't return anything. > > Here is an example doing a slug: > > def default_slug(context): > if not context.current_parameters['slug']: > return slugify(context.current_parameters['name']) > > on default the works since an insert will definitely be defining a name, > but on update, if we only update the description, then both 'slug' and > 'name' wouldn't be there, so I wouldn't want to do anything, but since its > running onupdate if I return nothing, it'll assume I want to set the value > to None, which is not the case. > > > Thanks > >
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/VuHQQ0AtIO8J. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.