- Temporarily rolled back the "ORDER BY" enhancement

from [ticket:1068].  This feature is on hold
pending further development.
This commit is contained in:
Mike Bayer
2008-08-06 15:46:31 +00:00
parent 4cd1902796
commit 665cd4d36a
11 changed files with 14 additions and 68 deletions
+5 -1
View File
@@ -5,7 +5,6 @@ CHANGES
=======
0.5beta4
========
- orm
- The RowTuple object returned by Query(*cols) now
features keynames which prefer mapped attribute
@@ -17,6 +16,11 @@ CHANGES
Column objects such as Query(table.c.col) will
return the "key" attribute of the Column.
- sql
- Temporarily rolled back the "ORDER BY" enhancement
from [ticket:1068]. This feature is on hold
pending further development.
0.5beta3
========
- 0.5beta3 includes all bugfixes listed under release
-1
View File
@@ -170,7 +170,6 @@ 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)
-1
View File
@@ -310,7 +310,6 @@ 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)
+2 -3
View File
@@ -202,7 +202,6 @@ 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
@@ -415,12 +414,12 @@ class InfoCompiler(compiler.DefaultCompiler):
else:
return compiler.DefaultCompiler.visit_function( self , func )
def visit_clauselist(self, list, within_order_by=False, **kwargs):
def visit_clauselist(self, list, **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, within_order_by=within_order_by) for c in li] if s is not None])
return ', '.join([s for s in [self.process(c) for c in li] if s is not None])
class InfoSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, first_pk=False):
-1
View File
@@ -473,7 +473,6 @@ 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'
-1
View File
@@ -361,7 +361,6 @@ class MSSQLExecutionContext_pyodbc (MSSQLExecutionContext):
class MSSQLDialect(default.DefaultDialect):
name = 'mssql'
supports_simple_order_by_label = False
colspecs = {
sqltypes.Unicode : MSNVarchar,
-1
View File
@@ -240,7 +240,6 @@ 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)
-1
View File
@@ -455,7 +455,6 @@ 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:
-1
View File
@@ -40,7 +40,6 @@ class DefaultDialect(base.Dialect):
dbapi_type_map = {}
default_paramstyle = 'named'
supports_default_values = True
supports_simple_order_by_label = True
def __init__(self, convert_unicode=False, assert_unicode=False, encoding='utf-8', paramstyle=None, dbapi=None, **kwargs):
self.convert_unicode = convert_unicode
+6 -10
View File
@@ -226,7 +226,7 @@ class DefaultCompiler(engine.Compiled):
def visit_grouping(self, grouping, **kwargs):
return "(" + self.process(grouping.element) + ")"
def visit_label(self, label, result_map=None, within_columns_clause=False, within_order_by=False):
def visit_label(self, label, result_map=None, within_columns_clause=False):
# only render labels within the columns clause
# or ORDER BY clause of a select. dialect-specific compilers
# can modify this behavior.
@@ -237,10 +237,6 @@ class DefaultCompiler(engine.Compiled):
result_map[labelname.lower()] = (label.name, (label, label.element, labelname), label.element.type)
return " ".join([self.process(label.element), self.operator_string(operators.as_), self.preparer.format_label(label, labelname)])
elif within_order_by and self.dialect.supports_simple_order_by_label:
labelname = self._truncated_identifier("colident", label.name)
return self.preparer.format_label(label, labelname)
else:
return self.process(label.element)
@@ -311,7 +307,7 @@ class DefaultCompiler(engine.Compiled):
def visit_null(self, null, **kwargs):
return 'NULL'
def visit_clauselist(self, clauselist, within_order_by=False, **kwargs):
def visit_clauselist(self, clauselist, **kwargs):
sep = clauselist.operator
if sep is None:
sep = " "
@@ -319,7 +315,7 @@ class DefaultCompiler(engine.Compiled):
sep = ', '
else:
sep = " " + self.operator_string(clauselist.operator) + " "
return sep.join(s for s in (self.process(c, within_order_by=within_order_by) for c in clauselist.clauses)
return sep.join(s for s in (self.process(c) for c in clauselist.clauses)
if s is not None)
def visit_calculatedclause(self, clause, **kwargs):
@@ -371,8 +367,8 @@ class DefaultCompiler(engine.Compiled):
else:
return text
def visit_unary(self, unary, within_order_by=False, **kwargs):
s = self.process(unary.element, within_order_by=within_order_by)
def visit_unary(self, unary, **kwargs):
s = self.process(unary.element)
if unary.operator:
s = self.operator_string(unary.operator) + " " + s
if unary.modifier:
@@ -564,7 +560,7 @@ class DefaultCompiler(engine.Compiled):
return select._distinct and "DISTINCT " or ""
def order_by_clause(self, select):
order_by = self.process(select._order_by_clause, within_order_by=True)
order_by = self.process(select._order_by_clause)
if order_by:
return " ORDER BY " + order_by
else:
+1 -47
View File
@@ -327,53 +327,7 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
x = func.lala(table1.c.myid).label('foo')
self.assert_compile(select([x], x==5), "SELECT lala(mytable.myid) AS foo FROM mytable WHERE lala(mytable.myid) = :param_1")
def test_labels_in_expressions(self):
"""test that label() constructs in ORDER BY render as the labelname.
Postgres' behavior was used as the guide for this,
so that only a simple label expression
and not a more complex expression involving the label
name would be rendered using the label name.
"""
lab1 = (table1.c.myid + "12").label('foo')
lab2 = func.somefunc(table1.c.name).label('bar')
dialect = default.DefaultDialect()
self.assert_compile(select([lab1, lab2]).order_by(lab1, desc(lab2)),
"SELECT mytable.myid + :myid_1 AS foo, somefunc(mytable.name) AS bar FROM mytable ORDER BY foo, bar DESC",
dialect=dialect
)
# the function embedded label renders as the function
self.assert_compile(select([lab1, lab2]).order_by(func.hoho(lab1), desc(lab2)),
"SELECT mytable.myid + :myid_1 AS foo, somefunc(mytable.name) AS bar FROM mytable ORDER BY hoho(mytable.myid + :myid_1), bar DESC",
dialect=dialect
)
# binary expressions render as the expression without labels
self.assert_compile(select([lab1, lab2]).order_by(lab1 + "test"),
"SELECT mytable.myid + :myid_1 AS foo, somefunc(mytable.name) AS bar FROM mytable ORDER BY mytable.myid + :myid_1 + :param_1",
dialect=dialect
)
# labels within functions in the columns clause render with the expression
self.assert_compile(
select([lab1, func.foo(lab1)]),
"SELECT mytable.myid + :myid_1 AS foo, foo(mytable.myid + :myid_1) AS foo_1 FROM mytable",
dialect=dialect
)
dialect = default.DefaultDialect()
dialect.supports_simple_order_by_label = False
self.assert_compile(select([lab1, lab2]).order_by(lab1, desc(lab2)),
"SELECT mytable.myid + :myid_1 AS foo, somefunc(mytable.name) AS bar FROM mytable ORDER BY mytable.myid + :myid_1, somefunc(mytable.name) DESC",
dialect=dialect
)
self.assert_compile(select([lab1, lab2]).order_by(func.hoho(lab1), desc(lab2)),
"SELECT mytable.myid + :myid_1 AS foo, somefunc(mytable.name) AS bar FROM mytable ORDER BY hoho(mytable.myid + :myid_1), somefunc(mytable.name) DESC",
dialect=dialect
)
def test_conjunctions(self):
self.assert_compile(