SELECT current_time
timez
---------
13:52:16.112571-05
SELECT current_time(2)
timez
---------
13:53:25.22-05
More widely, this thread brings up an interesting topic of the varying syntax of built-in database functions. The current SA syntax layer nicely abstracts away most of the common functionality of SELECT / UPDATE / INSERT variations.
But as it stands now it breaks down on database functions, which have widely varying implementations. For example, today + 3 days in PG is:
SELECT current_date + interval '3 days' as Saturday
saturday
-------------
2006-03-04 00:00:00
But in MS-SQL, it's
SELECT dateadd(d, 3, getdate()) as Saturday
Saturday
--------------
2006-03-04 14:16:19.060
Should SA even have a role in trying to "paper over" these kinds of differences?
Does it make sense to develop a set of function abstractions that would work across these databases?
Or would it be better to write a set of common UDF's for the various supported databases and call those instead?
Something to think about
Rick
On 3/1/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
this is very concerning, since other Postgresql functions only work
if you *dont* put parenthesis, like "current_date". the parenthesis
logic is currently based on the existence of arguments and was
explicitly added for that reason.
so, we will either have to add a flag to "func" to indicate "no
parenthesis", or somehow hardcode the postgres module to "know" when
it needs to put parenthesis and when it doesnt, which seems like it
would mean hardcoding of all the "non-parenthesis" function names.
what do you think ?
(to workaround immediately, use CURRENT_TIMESTAMP instead of now(),
or comment out the "visit_function" function in PGCompiler,
sqlalchemy/databases/postgres.py line 272)
On Mar 1, 2006, at 11:00 AM, Dennis wrote:
> I'd like to use func.now() in my select statement to get the current
> datetime from the db.. but I noticed that functions with no arguments
> are outputted without parens in the select sql..
>
> e.g.
> s=select(]func.now()],engine=db)
> str(s)
> 'select now'
>
> It should be 'select now()'
>
> Is there a workaround for this or is a patch needed?
>
> Thanks
> Dennis
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the
> live webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users