Kent wrote:
> Any chance you plan to make func.now consider oracle and
> use_ansi=False (and return sysdate)?

the use_ansi flag should be removed as far as public API since we can
detect server version now.   we can also make now() return sysdate()
unconditionally on oracle, you should give us a trac ticket for the latter
on milestone 0.6.



>
>
>
> On Feb 3, 4:44 pm, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
>> Kent wrote:
>> > Any chance SQLAlchemy has a mechanism to switch to or fromsysdatevs.
>> >current_datebased on the database dialect (and maybe use_ansi)?
>>
>> > It would be really nice if I could program in sqla not knowing which
>> > database type I am connected to and still could select the current
>> > date from the database... can I?
>>
>> func.now() does do this (well, it returns CURRENT_TIMESTAMP,
>> isCURRENT_DATEdifferent?).   it doesn't take use_ansi into account
>> though
>> (though that would be an easy patch to theOracledialect).
>>
>> Aside from all that, this is also easy enough to roll yourself:
>>
>> from sqlalchemy.sql.expression import ColumnElement
>> from sqlalchemy.ext.compiler import compiles
>>
>> classcurrent_date(ColumnElement):
>>     type = sa.DateTime()
>>
>> @compiler.compiles(current_date)
>> def _compiler_dispatch(element, compiler, **kw):
>>     if compiler.dialect.name == 'oracle':
>>         if not compiler.dialect.use_ansi:
>>             return "sysdate"
>>         else:
>>             return "current_date"
>>     else:
>>         # etc ...
>>
>> then just saycurrent_date() to get the expression.
>>
>> you could also throw @compiles onto "sqlalchemy.sql.functions.now" if
>> you
>> wanted to augment what func.now() returns.
>>
>>
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "sqlalchemy" group.
>> > To post to this group, send email to sqlalch...@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 sqlalch...@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 sqlalch...@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