- added "convert_unicode" flag to SQLEngine, will treat all String/CHAR types
as Unicode types, with raw-byte/utf-8 translation on the bind parameter and
result set side.
-
+- postgres maintains a list of ANSI functions that must have no parenthesis so
+function calls with no arguments work consistently
0.1.2
- fixed a recursive call in schema that was somehow running 994 times then returning
normally. broke nothing, slowed down everything. thanks to jpellerin for finding this.
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
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,
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,