Nice! I did not associate the custom typing in the docs with this functionality before. It would have saved me a lot of time!
Thank you very much again! g. On Tue, Oct 8, 2013 at 7:12 AM, Michael Bayer <[email protected]>wrote: > > On Oct 7, 2013, at 10:26 PM, tiadobatima <[email protected]> wrote: > > > Hello there, > > > > I see that Column() has "default", "onupdate", and "server_default" to > be used when the value for that column is not present when inserting and > updating... > > What would be the best way of rewriting a value that is present when > inserting or updating? > > if this is only Core, if you want to intercept statements and make > modifications you'd use execution events, e.g. before_execute: > http://docs.sqlalchemy.org/en/rel_0_8/core/events.html#sqlalchemy.events.ConnectionEvents.before_execute > > alternatively, you can use custom types to intercept values, e.g. > TypeDecorator: > > > http://docs.sqlalchemy.org/en/rel_0_8/core/types.html?highlight=typedecorator#sqlalchemy.types.TypeDecorator > > > > > Similarly, is there any easy way of rewriting the value of a column when > selecting? > > > the only system that allows interception of result row values at the Core > level is the typing system so you'd have to use TypeDecorator here. You > can produce ad-hoc type changes using type_coerce (see the example for an > ad-hoc rewrite of a string value to a GUID): > > > http://docs.sqlalchemy.org/en/rel_0_8/core/sqlelement.html?highlight=type_coerce#sqlalchemy.sql.expression.type_coerce > > > -- 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. For more options, visit https://groups.google.com/groups/opt_out.
