summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ansisql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-06-17 00:53:33 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-06-17 00:53:33 +0000
commit1ffed8432e282aa57ecde9f3e4ca778a1756ddc0 (patch)
tree0849938da765ee182bc23284337b214e3202e5d1 /lib/sqlalchemy/ansisql.py
parent3736b3ddff65f6d4b7e273b040b48b19dbac9b66 (diff)
downloadsqlalchemy-1ffed8432e282aa57ecde9f3e4ca778a1756ddc0.tar.gz
cast converted into its own ClauseElement so that it can have an explicit compilationrel_0_2_3
function in ANSICompiler MySQLCompiler then skips most CAST calls since it only seems to support the standard syntax for Date types; other types now a TODO for MySQL then, polymorphic_union() function now CASTs null()s to the type corresponding to the columns in the UNION, since postgres doesnt like mixing NULL with integer types (long road for that .....)
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r--lib/sqlalchemy/ansisql.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py
index cdd860440..82abb9577 100644
--- a/lib/sqlalchemy/ansisql.py
+++ b/lib/sqlalchemy/ansisql.py
@@ -231,7 +231,13 @@ class ANSICompiler(sql.Compiled):
self.strings[list] = "(" + string.join([self.get_str(c) for c in list.clauses], ' ') + ")"
else:
self.strings[list] = string.join([self.get_str(c) for c in list.clauses], ' ')
-
+
+ def visit_cast(self, cast):
+ if len(self.select_stack):
+ # not sure if we want to set the typemap here...
+ self.typemap.setdefault("CAST", cast.type)
+ self.strings[cast] = "CAST(%s AS %s)" % (self.strings[cast.clause],self.strings[cast.typeclause])
+
def visit_function(self, func):
if len(self.select_stack):
self.typemap.setdefault(func.name, func.type)