On Jun 13, 2013, at 12:03 PM, Florian Müller <[email protected]> wrote:
> HI! > > I implemented a TypeDecorator which allows setting the precision of a > datetime value. > > It does something like: > > import datetime > > class PrecisionDateTime(TypeDecorator): > def process_bind_param(self, value, dialect): > return datetime.datetime(value.year, value.month, > value.hour, value.minute, > 0, 0) > > This works but the problem is, that I have to call Session.refresh() on every > added (and flushed) > object because otherwise the date-column still has the old value (with second > != 0 and millisecond != 0). > > Is there a way the refresh could be avoided? you'd want to switch/augment by using a @validates rule: http://docs.sqlalchemy.org/en/rel_0_8/orm/mapper_config.html?highlight=validates#simple-validators -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
