Commits

Mike Bayer committed 35814f0 Merge

merge

  • Participants
  • Parent commits 79bf40a, f5dff64

Comments (0)

Files changed (5)

File lib/sqlalchemy/dialects/mssql/base.py

                 self.root_connection._cursor_execute(self.cursor,
                     "SET IDENTITY_INSERT %s ON" %
                     self.dialect.identifier_preparer.format_table(tbl),
-                    ())
+                    (), self)
 
     def post_exec(self):
         """Disable IDENTITY_INSERT if enabled."""
         if self._select_lastrowid:
             if self.dialect.use_scope_identity:
                 conn._cursor_execute(self.cursor,
-                    "SELECT scope_identity() AS lastrowid", ())
+                    "SELECT scope_identity() AS lastrowid", (), self)
             else:
                 conn._cursor_execute(self.cursor,
-                    "SELECT @@identity AS lastrowid", ())
+                    "SELECT @@identity AS lastrowid", (), self)
             # fetchall() ensures the cursor is consumed without closing it
             row = self.cursor.fetchall()[0]
             self._lastrowid = int(row[0])
                         "SET IDENTITY_INSERT %s OFF" %
                             self.dialect.identifier_preparer.
                                 format_table(self.compiled.statement.table),
-                        ()
-                        )
+                        (), self)
 
     def get_lastrowid(self):
         return self._lastrowid

File lib/sqlalchemy/engine/base.py

             for fn in self.dispatch.before_cursor_execute:
                 statement, parameters = \
                             fn(self, cursor, statement, parameters,
-                                        context, context.executemany)
+                                        context, 
+                                        context.executemany 
+                                           if context is not None else False)
 
         if self._echo:
             self.engine.logger.info(statement)

File lib/sqlalchemy/exc.py

         return ' '.join((SQLAlchemyError.__str__(self),
                          repr(self.statement), repr(params_repr)))
 
+    def __unicode__(self):
+        return self.__str__()
 
 class DBAPIError(StatementError):
     """Raised when the execution of a database operation fails.

File test/engine/test_ddlevents.py

         default_from = testing.db.dialect.statement_compiler(
                             testing.db.dialect, None).default_from()
 
-        eq_(
-            testing.db.execute(
-                text("select 'foo%something'" + default_from)
-            ).scalar(),
-            'foo%something'
-        )
+        # We're abusing the DDL()
+        # construct here by pushing a SELECT through it
+        # so that we can verify the round trip.        
+        # the DDL() will trigger autocommit, which prohibits
+        # some DBAPIs from returning results (pyodbc), so we
+        # run in an explicit transaction.   
+        with testing.db.begin() as conn:
+            eq_(
+                conn.execute(
+                    text("select 'foo%something'" + default_from)
+                ).scalar(),
+                'foo%something'
+            )
 
-        eq_(
-            testing.db.execute(
-                DDL("select 'foo%%something'" + default_from)
-            ).scalar(),
-            'foo%something'
-        )
+            eq_(
+                conn.execute(
+                    DDL("select 'foo%%something'" + default_from)
+                ).scalar(),
+                'foo%something'
+            )
 
 
 

File test/engine/test_execute.py

 
         for engine in [
             engines.testing_engine(options=dict(implicit_returning=False)),
-            engines.testing_engine(options=dict(implicit_returning=False,
-                                   strategy='threadlocal')),
-            engines.testing_engine(options=dict(implicit_returning=False)).\
-                connect()
+            #engines.testing_engine(options=dict(implicit_returning=False,
+            #                       strategy='threadlocal')),
+            #engines.testing_engine(options=dict(implicit_returning=False)).\
+            #    connect()
             ]:
             event.listen(engine, 'before_execute', execute)
             event.listen(engine, 'before_cursor_execute', cursor_execute)