summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES13
-rw-r--r--lib/sqlalchemy/sql/expression.py3
-rw-r--r--test/sql/select.py5
3 files changed, 16 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 5ef21fa24..6070b97d8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,7 +13,7 @@ CHANGES
now concatenate the wildcard operator with the given
operand in SQL, i.e. "'%' || <bindparam>" in all cases,
accept text('something') operands properly [ticket:962]
-
+
- cast() accepts text('something') and other non-literal
operands properly [ticket:962]
@@ -24,7 +24,7 @@ CHANGES
DELETE etc., this flag will enable "autocommit" behavior
during execution if no transaction is in progress
[ticket:915]
-
+
- The '.c.' attribute on a selectable now gets an entry
for every column expression in its columns clause.
Previously, "unnamed" columns like functions and CASE
@@ -46,12 +46,17 @@ CHANGES
up their ".c." collection based on the names present in
the first selectable only; corresponding_column() now
works fully for all embedded selectables.
-
+
- Oracle and others properly encode SQL used for defaults
like sequences, etc., even if no unicode idents are used
since identifier preparer may return a cached unicode
identifier.
-
+
+ - Column and clause comparisons to datetime objects on the
+ left hand side of the expression now work (d < table.c.col).
+ (datetimes on the RHS have always worked, the LHS exception
+ is a quirk of the datetime implementation.)
+
- orm
- Every Session.begin() must now be accompanied by a
corresponding commit() or rollback() unless the session
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index ee867a2f9..c0b46a182 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1111,6 +1111,9 @@ class Operators(object):
class ColumnOperators(Operators):
"""Defines comparison and math operations."""
+ timetuple = None
+ """Hack, allows datetime objects to be compared on the LHS."""
+
def __lt__(self, other):
return self.operate(operators.lt, other)
diff --git a/test/sql/select.py b/test/sql/select.py
index 522f9a2ff..3585a2cd7 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -1,5 +1,5 @@
import testenv; testenv.configure_for_tests()
-import re, operator
+import datetime, re, operator
from sqlalchemy import *
from sqlalchemy import exceptions, sql, util
from sqlalchemy.sql import table, column
@@ -387,6 +387,7 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
):
self.assert_compile(py_op(lhs, rhs), res % sql_op)
+ dt = datetime.datetime.today()
# exercise comparison operators
for (py_op, fwd_op, rev_op) in ((operator.lt, '<', '>'),
(operator.gt, '>', '<'),
@@ -403,6 +404,8 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
(literal('a'), 'b', ':param_1', ':param_2'),
(literal('a'), table1.c.myid, ':param_1', 'mytable.myid'),
(literal('a'), literal('b'), ':param_1', ':param_2'),
+ (dt, literal('b'), ':param_2', ':param_1'),
+ (literal('b'), dt, ':param_1', ':param_2'),
):
# the compiled clause should match either (e.g.):