summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases
diff options
context:
space:
mode:
authorPaul Johnston <paj@pajhome.org.uk>2007-07-17 22:32:16 +0000
committerPaul Johnston <paj@pajhome.org.uk>2007-07-17 22:32:16 +0000
commitaa299318a96dd8cb2e887b24431bc296c7f108cc (patch)
tree8008cb22bd5b14df6982be9c9cc024f59cb4ef7b /lib/sqlalchemy/databases
parent0c578f31b6d25555a80e7bf1cbbac0f7a4bb4491 (diff)
downloadsqlalchemy-aa299318a96dd8cb2e887b24431bc296c7f108cc.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 0e5a41a34..3f181c5bb 100644
--- a/lib/sqlalchemy/databases/mssql.py
+++ b/lib/sqlalchemy/databases/mssql.py
@@ -246,8 +246,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()
@@ -259,8 +258,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:
@@ -531,7 +529,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 7ccf38c4b..70cbd0c0e 100644
--- a/lib/sqlalchemy/databases/sqlite.py
+++ b/lib/sqlalchemy/databases/sqlite.py
@@ -235,7 +235,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()
@@ -273,7 +273,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()
@@ -302,7 +302,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()