From 1ffed8432e282aa57ecde9f3e4ca778a1756ddc0 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 17 Jun 2006 00:53:33 +0000 Subject: cast converted into its own ClauseElement so that it can have an explicit compilation 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 .....) --- lib/sqlalchemy/databases/mysql.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/databases/mysql.py') diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index aa05134d0..e32d6f120 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -9,7 +9,6 @@ import sys, StringIO, string, types, re, datetime from sqlalchemy import sql,engine,schema,ansisql from sqlalchemy.engine import default import sqlalchemy.types as sqltypes -import sqlalchemy.databases.information_schema as ischema import sqlalchemy.exceptions as exceptions try: @@ -250,6 +249,15 @@ class MySQLDialect(ansisql.ANSIDialect): class MySQLCompiler(ansisql.ANSICompiler): + def visit_cast(self, cast): + """hey ho MySQL supports almost no types at all for CAST""" + if (isinstance(cast.type, sqltypes.Date) or isinstance(cast.type, sqltypes.Time) or isinstance(cast.type, sqltypes.DateTime)): + return super(MySQLCompiler, self).visit_cast(cast) + else: + # so just skip the CAST altogether for now. + # TODO: put whatever MySQL does for CAST here. + self.strings[cast] = self.strings[cast.clause] + def limit_clause(self, select): text = "" if select.limit is not None: -- cgit v1.2.1