On Apr 21, 2011, at 7:15 AM, Pedro Romano wrote:

> Hi,
> 
> Is there any way to set a column default to be a different server
> function depending on the dialect? For python function defaults, this
> is trivial using a context-sensitive default function and getting the
> dialect from the context, however these don't cover server functions
> for defaults, since these are inlined in the statement.
> 
> Silly example just to make what a I need clear:
> 
> for 'MySQL' I would like the column default to be:
> 
> default=func.utc_timestamp()
> 
> and for all other dialects:
> 
> default=func.current_timestamp()
> 
> Thanks to all SA authors and contributors for making such an excellent
> and invaluable toolkit!

you use the @compiles decorator and an example of a UTC timestamp construct is 
at: 

http://www.sqlalchemy.org/docs/07/core/compiler.html?highlight=timestamp#utc-timestamp-function



> 
> --Pedro.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> 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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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.

Reply via email to