diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-01 19:43:07 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-01 19:43:07 +0000 |
| commit | fd8567037269ac937a6b079c6e00022abfc51149 (patch) | |
| tree | 00d10f99b40a55b1dd60f1dfe5c00abe0ec27618 /lib/sqlalchemy/databases/postgres.py | |
| parent | 371a6ca0de39b0affc25852b782898f2497eaeb0 (diff) | |
| download | sqlalchemy-fd8567037269ac937a6b079c6e00022abfc51149.tar.gz | |
postgres leaves parenthesis off functions only for no-argument ANSI functions according to a list
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
| -rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 67e3d5cf5..13714ba3e 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -6,6 +6,7 @@ import sys, StringIO, string, types, re +import sqlalchemy.util as util import sqlalchemy.sql as sql import sqlalchemy.engine as engine import sqlalchemy.schema as schema @@ -101,7 +102,18 @@ class PGBinary(sqltypes.Binary): class PGBoolean(sqltypes.Boolean): def get_col_spec(self): return "BOOLEAN" - + +ANSI_FUNCS = util.HashSet([ +'CURRENT_TIME', +'CURRENT_TIMESTAMP', +'CURRENT_DATE', +'LOCAL_TIME', +'LOCAL_TIMESTAMP', +'CURRENT_USER', +'SESSION_USER', +'USER' +]) + pg2_colspecs = { sqltypes.Integer : PGInteger, sqltypes.Smallinteger : PGSmallInteger, @@ -270,10 +282,11 @@ class PGSQLEngine(ansisql.ANSISQLEngine): class PGCompiler(ansisql.ANSICompiler): def visit_function(self, func): - if len(func.clauses): - super(PGCompiler, self).visit_function(func) - else: + # PG has a bunch of funcs that explicitly need no parenthesis + if func.name.upper() in ANSI_FUNCS and not len(func.clauses): self.strings[func] = func.name + else: + super(PGCompiler, self).visit_function(func) def visit_insert_column(self, column): # Postgres advises against OID usage and turns it off in 8.1, |
