]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- the "op()" function is now treated as an "operation", rather than a "comparison".
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 8 Jan 2007 19:09:02 +0000 (19:09 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 8 Jan 2007 19:09:02 +0000 (19:09 +0000)
  the difference is, an operation produces a BinaryExpression from which further operations
  can occur whereas comparison produces the more restrictive BooleanExpression

CHANGES
lib/sqlalchemy/sql.py
test/sql/select.py

diff --git a/CHANGES b/CHANGES
index 81e5742080830c14c3b9d943e348f8c60edf792e..a7f3d2e047471a361c155d7fe0d616d3c3e0e307 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,9 @@
   - default "timezone" setting is now False.  this corresponds to Python's datetime
   behavior as well as Postgres' timestamp/time types (which is the only timezone-sensitive
   dialect at the moment) [ticket:414]
+  - the "op()" function is now treated as an "operation", rather than a "comparison".
+  the difference is, an operation produces a BinaryExpression from which further operations
+  can occur whereas comparison produces the more restrictive BooleanExpression
 - firebird:
   - order of constraint creation puts primary key first before all other constraints;
   required for firebird, not a bad idea for others [ticket:408]
index 98191552ba868aaf45592a235f9d53bb42105930..f6e23d583a356663476a23bc5f1a00373049de17 100644 (file)
@@ -562,7 +562,7 @@ class _CompareMixin(object):
     def between(self, cleft, cright):
         return _BooleanExpression(self, and_(self._check_literal(cleft), self._check_literal(cright)), 'BETWEEN')
     def op(self, operator):
-        return lambda other: self._compare(operator, other)
+        return lambda other: self._operate(operator, other)
     # and here come the math operators:
     def __add__(self, other):
         return self._operate('+', other)
index 5d91276e23fbf2262ad034c367b50bff611f703f..f1173665298fb8eaef7a11d25d1b541048df90b5 100644 (file)
@@ -220,6 +220,12 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
             literal("a") + literal("b") * literal("c"), ":literal + (:liter_1 * :liter_2)"
         )
 
+        # test the op() function, also that its results are further usable in expressions
+        self.runtest(
+            table1.select(table1.c.myid.op('hoho')(12)==14),
+            "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE (mytable.myid hoho :mytable_myid) = :literal"
+        )
+
     def testunicodestartswith(self):
         string = u"hi \xf6 \xf5"
         self.runtest(