]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added a hook in for 'binary operator', so sqlite can exchange
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 31 Dec 2005 07:49:33 +0000 (07:49 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 31 Dec 2005 07:49:33 +0000 (07:49 +0000)
'+' for '||' for a binary clause on a string

lib/sqlalchemy/ansisql.py
lib/sqlalchemy/databases/sqlite.py

index a4cbb43583c15eb961368635830f23178232c364..a06abe598740e15ef1e911163ac0c97aa4ba45c5 100644 (file)
@@ -209,12 +209,15 @@ class ANSICompiler(sql.Compiled):
     def visit_binary(self, binary):
         result = self.get_str(binary.left)
         if binary.operator is not None:
-            result += " " + binary.operator
+            result += " " + self.binary_operator_string(binary)
         result += " " + self.get_str(binary.right)
         if binary.parens:
             result = "(" + result + ")"
         self.strings[binary] = result
 
+    def binary_operator_string(self, binary):
+        return binary.operator
+
     def visit_bindparam(self, bindparam):
         if bindparam.shortname != bindparam.key:
             self.binds[bindparam.shortname] = bindparam
index 26cc3cf05c31df4672ddcab9125728f56003f356..0288beae89e1abf51beefc3b2c62e0e4c643ac69 100644 (file)
@@ -185,7 +185,11 @@ class SQLiteCompiler(ansisql.ANSICompiler):
                 text += " \n LIMIT -1"
             text += " OFFSET " + str(select.offset)
         return text
-
+    def binary_operator_string(self, binary):
+        if isinstance(binary.type, sqltypes.String) and binary.operator == '+':
+            return '||'
+        else:
+            return ansisql.ANSICompiler.binary_operator_string(self, binary)
         
 class SQLiteSchemaGenerator(ansisql.ANSISchemaGenerator):
     def get_column_specification(self, column, override_pk=False, **kwargs):