summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mysql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-08-12 17:28:15 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-08-12 17:28:15 +0000
commit9e8fad2abcce364253352f042836bf58ce8f4f81 (patch)
tree5058c15280a2e56d454670deeb7a53dd8b6b1f67 /lib/sqlalchemy/databases/mysql.py
parentfb88b031d916ea91ce9af760a67ea27e00113c14 (diff)
downloadsqlalchemy-9e8fad2abcce364253352f042836bf58ce8f4f81.tar.gz
quoting facilities set up so that database-specific quoting can be
turned on for individual table, schema, and column identifiers when used in all queries/creates/drops. Enabled via "quote=True" in Table or Column, as well as "quote_schema=True" in Table. Thanks to Aaron Spike for his excellent efforts. [ticket:155]
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r--lib/sqlalchemy/databases/mysql.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index df661daac..56f2125ac 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -298,6 +298,9 @@ class MySQLDialect(ansisql.ANSIDialect):
def schemadropper(self, *args, **kwargs):
return MySQLSchemaDropper(*args, **kwargs)
+ def preparer(self):
+ return MySQLIdentifierPreparer()
+
def do_rollback(self, connection):
# some versions of MySQL just dont support rollback() at all....
try:
@@ -428,7 +431,7 @@ class MySQLCompiler(ansisql.ANSICompiler):
class MySQLSchemaGenerator(ansisql.ANSISchemaGenerator):
def get_column_specification(self, column, override_pk=False, first_pk=False):
- colspec = column.name + " " + column.type.engine_impl(self.engine).get_col_spec()
+ colspec = self.preparer.format_column(column) + " " + column.type.engine_impl(self.engine).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
colspec += " DEFAULT " + default
@@ -452,4 +455,14 @@ class MySQLSchemaDropper(ansisql.ANSISchemaDropper):
self.append("\nDROP INDEX " + index.name + " ON " + index.table.name)
self.execute()
+class MySQLIdentifierPreparer(ansisql.ANSIIdentifierPreparer):
+ def __init__(self):
+ super(MySQLIdentifierPreparer, self).__init__(initial_quote='`')
+ def _escape_identifier(self, value):
+ #TODO: determin MySQL's escaping rules
+ return value
+ def _fold_identifier_case(self, value):
+ #TODO: determin MySQL's case folding rules
+ return value
+
dialect = MySQLDialect