zzzeek / test_sqlalchemy

0 stars 0 forks source link

ms-sql fails during reflection #901

Closed sqlalchemy-bot closed 10 years ago

sqlalchemy-bot commented 16 years ago

Issue created by Anonymous


sp_columns is called during reflection of tables... right now it's called with the schema prepended, like 'dbo.mytable'. this is incorrect syntax (on 2005 at least). i've attached a patch which lets it work.

HTH, --craig

#!diff
Index: lib/sqlalchemy/databases/mssql.py
===================================================================
--- lib/sqlalchemy/databases/mssql.py   (revision 3933)
+++ lib/sqlalchemy/databases/mssql.py   (working copy)
@@ -605,7 +605,10 @@
             raise exceptions.NoSuchTableError(table.name)

         # We also run an sp_columns to check for identity columns:
-        cursor = connection.execute("sp_columns %s" % self.identifier_preparer.format_table(table))
+        cursor = connection.execute(
+            "sp_columns @table_name = '%s', @table_owner = '%s'"
+            % (table.name, current_schema))
+        
         ic = None
         while True:
             row = cursor.fetchone()

Attachments: p1.patch

sqlalchemy-bot commented 10 years ago

Michael Bayer (zzzeek) wrote:


Removing milestone: 0.4.xx (automated comment)

sqlalchemy-bot commented 16 years ago

Michael Bayer (zzzeek) wrote:


sqlalchemy-bot commented 16 years ago

Anonymous wrote:


whoops... wiki didn't like the patch. attached.

sqlalchemy-bot commented 16 years ago

Anonymous wrote:


(original author: ram) 116e19f7f0c9a7c50ea52825a70ac00a83e95fa8, thanks for the patch