summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases
diff options
context:
space:
mode:
authorPaul Johnston <paj@pajhome.org.uk>2007-07-17 20:13:36 +0000
committerPaul Johnston <paj@pajhome.org.uk>2007-07-17 20:13:36 +0000
commita966505992b94ec1cc0633aafa7dda0a287fb96c (patch)
treeb2c40729792b7ab343169f6ddcc2667c778ee00e /lib/sqlalchemy/databases
parent1dba9d48c28d59523f952d5e6b2f1425450cd7db (diff)
downloadsqlalchemy-a966505992b94ec1cc0633aafa7dda0a287fb96c.tar.gz
Properly escape table names when reflecting for mssql and sqlite [ticket:653]
Diffstat (limited to 'lib/sqlalchemy/databases')
-rw-r--r--lib/sqlalchemy/databases/mssql.py8
-rw-r--r--lib/sqlalchemy/databases/sqlite.py6
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py
index 553e07a48..6b1b41123 100644
--- a/lib/sqlalchemy/databases/mssql.py
+++ b/lib/sqlalchemy/databases/mssql.py
@@ -251,8 +251,7 @@ class MSSQLExecutionContext(default.DefaultExecutionContext):
self.IINSERT = False
if self.IINSERT:
- # TODO: quoting rules for table name here ?
- self.cursor.execute("SET IDENTITY_INSERT %s ON" % self.compiled.statement.table.fullname)
+ self.cursor.execute("SET IDENTITY_INSERT %s ON" % self.dialect.preparer().format_table(self.compiled.statement.table))
super(MSSQLExecutionContext, self).pre_exec()
@@ -264,8 +263,7 @@ class MSSQLExecutionContext(default.DefaultExecutionContext):
if self.compiled.isinsert:
if self.IINSERT:
- # TODO: quoting rules for table name here ?
- self.cursor.execute("SET IDENTITY_INSERT %s OFF" % self.compiled.statement.table.fullname)
+ self.cursor.execute("SET IDENTITY_INSERT %s OFF" % self.dialect.preparer().format_table(self.compiled.statement.table))
self.IINSERT = False
elif self.HASIDENT:
if not len(self._last_inserted_ids) or self._last_inserted_ids[0] is None:
@@ -532,7 +530,7 @@ class MSSQLDialect(ansisql.ANSIDialect):
raise exceptions.NoSuchTableError(table.name)
# We also run an sp_columns to check for identity columns:
- cursor = connection.execute("sp_columns " + table.name)
+ cursor = connection.execute("sp_columns " + self.preparer().format_table(table))
ic = None
while True:
row = cursor.fetchone()
diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py
index b42468c7a..5c4a38b5d 100644
--- a/lib/sqlalchemy/databases/sqlite.py
+++ b/lib/sqlalchemy/databases/sqlite.py
@@ -233,7 +233,7 @@ class SQLiteDialect(ansisql.ANSIDialect):
return (row is not None)
def reflecttable(self, connection, table):
- c = connection.execute("PRAGMA table_info(" + table.name + ")", {})
+ c = connection.execute("PRAGMA table_info(%s)" % self.preparer().format_table(table), {})
found_table = False
while True:
row = c.fetchone()
@@ -266,7 +266,7 @@ class SQLiteDialect(ansisql.ANSIDialect):
if not found_table:
raise exceptions.NoSuchTableError(table.name)
- c = connection.execute("PRAGMA foreign_key_list(" + table.name + ")", {})
+ c = connection.execute("PRAGMA foreign_key_list(%s)" % self.preparer().format_table(table), {})
fks = {}
while True:
row = c.fetchone()
@@ -295,7 +295,7 @@ class SQLiteDialect(ansisql.ANSIDialect):
for name, value in fks.iteritems():
table.append_constraint(schema.ForeignKeyConstraint(value[0], value[1]))
# check for UNIQUE indexes
- c = connection.execute("PRAGMA index_list(" + table.name + ")", {})
+ c = connection.execute("PRAGMA index_list(%s)" % self.preparer().format_table(table), {})
unique_indexes = []
while True:
row = c.fetchone()