summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-08-03 21:19:32 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-08-03 21:19:32 +0000
commitedf6b16fae38b4c103ed2827ee5448fec2fdcb1a (patch)
tree2d02c785663acab948e3ab8cf65e50ba738e60b6 /lib/sqlalchemy/databases
parent8df49e7194f272573f043343e601c4ee4beb0f70 (diff)
downloadsqlalchemy-edf6b16fae38b4c103ed2827ee5448fec2fdcb1a.tar.gz
- compiler visit_label() checks a flag "within_order_by" and will render its own name
and not its contained expression, if the dialect reports true for supports_simple_order_by_label. the flag is not propagated forwards, meant to closely mimic the syntax Postgres expects which is that only a simple name can be in the ORDER BY, not a more complex expression or function call with the label name embedded (mysql and sqlite support more complex expressions). This further sets the standard for propigation of **kwargs within compiler, that we can't just send **kwargs along blindly to each XXX.process() call; whenever a **kwarg needs to propagate through, most methods will have to be aware of it and know when they should send it on forward and when not. This was actually already the case with result_map as well. The supports_simple_order_by dialect flag defaults to True but is conservatively explicitly set to False on all dialects except SQLite/MySQL/Postgres to start. [ticket:1068]
Diffstat (limited to 'lib/sqlalchemy/databases')
-rw-r--r--lib/sqlalchemy/databases/access.py1
-rw-r--r--lib/sqlalchemy/databases/firebird.py3
-rw-r--r--lib/sqlalchemy/databases/informix.py5
-rw-r--r--lib/sqlalchemy/databases/maxdb.py1
-rw-r--r--lib/sqlalchemy/databases/mssql.py2
-rw-r--r--lib/sqlalchemy/databases/oracle.py1
-rw-r--r--lib/sqlalchemy/databases/postgres.py2
-rw-r--r--lib/sqlalchemy/databases/sybase.py1
8 files changed, 12 insertions, 4 deletions
diff --git a/lib/sqlalchemy/databases/access.py b/lib/sqlalchemy/databases/access.py
index 425c1eb69..0dfa62888 100644
--- a/lib/sqlalchemy/databases/access.py
+++ b/lib/sqlalchemy/databases/access.py
@@ -170,6 +170,7 @@ class AccessDialect(default.DefaultDialect):
name = 'access'
supports_sane_rowcount = False
supports_sane_multi_rowcount = False
+ supports_simple_order_by_label = False
def type_descriptor(self, typeobj):
newobj = types.adapt_type(typeobj, self.colspecs)
diff --git a/lib/sqlalchemy/databases/firebird.py b/lib/sqlalchemy/databases/firebird.py
index 33ae4feab..412f7bce6 100644
--- a/lib/sqlalchemy/databases/firebird.py
+++ b/lib/sqlalchemy/databases/firebird.py
@@ -310,6 +310,7 @@ class FBDialect(default.DefaultDialect):
max_identifier_length = 31
preexecute_pk_sequences = True
supports_pk_autoincrement = False
+ supports_simple_order_by_label = False
def __init__(self, type_conv=200, concurrency_level=1, **kwargs):
default.DefaultDialect.__init__(self, **kwargs)
@@ -675,7 +676,7 @@ class FBCompiler(sql.compiler.DefaultCompiler):
yield co
else:
yield c
- columns = [self.process(c, render_labels=True)
+ columns = [self.process(c, within_columns_clause=True)
for c in flatten_columnlist(returning_cols)]
text += ' RETURNING ' + ', '.join(columns)
return text
diff --git a/lib/sqlalchemy/databases/informix.py b/lib/sqlalchemy/databases/informix.py
index 130b08c41..39d0ee96a 100644
--- a/lib/sqlalchemy/databases/informix.py
+++ b/lib/sqlalchemy/databases/informix.py
@@ -202,6 +202,7 @@ class InfoDialect(default.DefaultDialect):
default_paramstyle = 'qmark'
# for informix 7.31
max_identifier_length = 18
+ supports_simple_order_by_label = False
def __init__(self, use_ansi=True, **kwargs):
self.use_ansi = use_ansi
@@ -414,12 +415,12 @@ class InfoCompiler(compiler.DefaultCompiler):
else:
return compiler.DefaultCompiler.visit_function( self , func )
- def visit_clauselist(self, list):
+ def visit_clauselist(self, list, within_order_by=False, **kwargs):
try:
li = [ c for c in list.clauses if c.name != 'oid' ]
except:
li = [ c for c in list.clauses ]
- return ', '.join([s for s in [self.process(c) for c in li] if s is not None])
+ return ', '.join([s for s in [self.process(c, within_order_by=within_order_by) for c in li] if s is not None])
class InfoSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, first_pk=False):
diff --git a/lib/sqlalchemy/databases/maxdb.py b/lib/sqlalchemy/databases/maxdb.py
index c9ea2b579..c51f1b431 100644
--- a/lib/sqlalchemy/databases/maxdb.py
+++ b/lib/sqlalchemy/databases/maxdb.py
@@ -473,6 +473,7 @@ class MaxDBDialect(default.DefaultDialect):
supports_sane_rowcount = True
supports_sane_multi_rowcount = False
preexecute_pk_sequences = True
+ supports_simple_order_by_label = False
# MaxDB-specific
datetimeformat = 'internal'
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py
index 0341d1823..f03856736 100644
--- a/lib/sqlalchemy/databases/mssql.py
+++ b/lib/sqlalchemy/databases/mssql.py
@@ -361,6 +361,8 @@ class MSSQLExecutionContext_pyodbc (MSSQLExecutionContext):
class MSSQLDialect(default.DefaultDialect):
name = 'mssql'
+ supports_simple_order_by_label = False
+
colspecs = {
sqltypes.Unicode : MSNVarchar,
sqltypes.Integer : MSInteger,
diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py
index f2e5ba2f6..8341e3401 100644
--- a/lib/sqlalchemy/databases/oracle.py
+++ b/lib/sqlalchemy/databases/oracle.py
@@ -240,6 +240,7 @@ class OracleDialect(default.DefaultDialect):
preexecute_pk_sequences = True
supports_pk_autoincrement = False
default_paramstyle = 'named'
+ supports_simple_order_by_label = False
def __init__(self, use_ansi=True, auto_setinputsizes=True, auto_convert_lobs=True, threaded=True, allow_twophase=True, arraysize=50, **kwargs):
default.DefaultDialect.__init__(self, **kwargs)
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index 5d61b32ad..744a573c9 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -703,7 +703,7 @@ class PGCompiler(compiler.DefaultCompiler):
yield co
else:
yield c
- columns = [self.process(c, render_labels=True) for c in flatten_columnlist(returning_cols)]
+ columns = [self.process(c, within_columns_clause=True) for c in flatten_columnlist(returning_cols)]
text += ' RETURNING ' + string.join(columns, ', ')
return text
diff --git a/lib/sqlalchemy/databases/sybase.py b/lib/sqlalchemy/databases/sybase.py
index aea77f8bf..dd55ac0d2 100644
--- a/lib/sqlalchemy/databases/sybase.py
+++ b/lib/sqlalchemy/databases/sybase.py
@@ -455,6 +455,7 @@ class SybaseSQLDialect(default.DefaultDialect):
supports_unicode_statements = False
supports_sane_rowcount = False
supports_sane_multi_rowcount = False
+ supports_simple_order_by_label = False
def __new__(cls, dbapi=None, *args, **kwargs):
if cls != SybaseSQLDialect: