Mike Bayer avatar Mike Bayer committed 7d9d413

mssql: - [bug] Fixed bug where reflection of primary key constraint
would double up columns if the same constraint/table
existed in multiple schemas.
- force returns_rows to False for inserts where we know rows shouldnt be returned;
allows post_exec() to use the cursor without issue

Comments (0)

Files changed (6)

     attribute, causing the construct to not compile
     correctly a second time.  [ticket:2545]
 
+  - [bug] Fixed bug where reflection of primary key constraint
+    would double up columns if the same constraint/table
+    existed in multiple schemas.
+
 0.7.8
 =====
 - orm

lib/sqlalchemy/dialects/mssql/base.py

         # Primary key constraints
         s = sql.select([C.c.column_name, TC.c.constraint_type],
             sql.and_(TC.c.constraint_name == C.c.constraint_name,
+                    TC.c.table_schema == C.c.table_schema,
                      C.c.table_name == tablename,
                      C.c.table_schema == owner)
         )

lib/sqlalchemy/engine/base.py

             if context._is_implicit_returning:
                 context._fetch_implicit_returning(result)
                 result.close(_autoclose_connection=False)
+                result._metadata = None
             elif not context._is_explicit_returning:
                 result.close(_autoclose_connection=False)
+                result._metadata = None
         elif result._metadata is None:
             # no results, get rowcount
             # (which requires open cursor on some drivers

lib/sqlalchemy/engine/result.py

     _process_row = RowProxy
     out_parameters = None
     _can_close_connection = False
+    _metadata = None
 
     def __init__(self, context):
         self.context = context
 
     def _init_metadata(self):
         metadata = self._cursor_description()
-        if metadata is None:
-            self._metadata = None
-        else:
+        if metadata is not None:
             self._metadata = ResultMetaData(self, metadata)
 
     def keys(self):

lib/sqlalchemy/testing/suite/test_ddl.py

 
     def _simple_fixture(self):
         return Table('test_table', self.metadata,
-                Column('id', Integer, primary_key=True),
+                Column('id', Integer, primary_key=True, autoincrement=False),
                 Column('data', String(50))
             )
 

lib/sqlalchemy/testing/suite/test_insert.py

         )
         assert r.closed
         assert r.is_insert
-        assert r.returns_rows
+        assert not r.returns_rows
 
 
 __all__ = ('InsertSequencingTest', 'InsertBehaviorTest')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.