]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The execution options passed to an :class:`.Engine` either via
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Oct 2014 22:23:42 +0000 (18:23 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Oct 2014 22:23:42 +0000 (18:23 -0400)
:paramref:`.create_engine.execution_options` or
:meth:`.Engine.update_execution_options` are not passed to the
special :class:`.Connection` used to initialize the dialect
within the "first connect" event; dialects will usually
perform their own queries in this phase, and none of the
current available  options should be applied here.  In
particular, the "autocommit" option was causing an attempt to
autocommit within this initial connect which would fail with
an AttributeError due to the non-standard state of the
:class:`.Connection`.
fixes #3200

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/engine/strategies.py
test/engine/test_execute.py

index e3d9175cb32e109f38622aee491adc0eb2f01df1..7dd50739e03b5feeee9ec14cea9095d5c6722b76 100644 (file)
 .. changelog::
     :version: 0.9.8
 
+    .. change::
+        :tags: bug, engine
+        :versions: 1.0.0
+        :tickets: 3200
+
+        The execution options passed to an :class:`.Engine` either via
+        :paramref:`.create_engine.execution_options` or
+        :meth:`.Engine.update_execution_options` are not passed to the
+        special :class:`.Connection` used to initialize the dialect
+        within the "first connect" event; dialects will usually
+        perform their own queries in this phase, and none of the
+        current available  options should be applied here.  In
+        particular, the "autocommit" option was causing an attempt to
+        autocommit within this initial connect which would fail with
+        an AttributeError due to the non-standard state of the
+        :class:`.Connection`.
+
     .. change::
         :tags: bug, sqlite
         :versions: 1.0.0
index 38206be89772efef4ff4315e7d41d254df46988f..49438372b54c3cadfba8ff40c6f857efa5a51640 100644 (file)
@@ -162,6 +162,7 @@ class DefaultEngineStrategy(EngineStrategy):
             def first_connect(dbapi_connection, connection_record):
                 c = base.Connection(engine, connection=dbapi_connection,
                                     _has_events=False)
+                c._execution_options = {}
                 dialect.initialize(c)
             event.listen(pool, 'first_connect', first_connect, once=True)
 
index 219a145c62a336e199717ab5ca9fea4603a4f485..a80d157ed25707d48bbcb574c5abdc564ad78903 100644 (file)
@@ -478,6 +478,14 @@ class ExecuteTest(fixtures.TestBase):
 
         eq_(canary, ["l1", "l2", "l3", "l1", "l2"])
 
+    @testing.requires.ad_hoc_engines
+    def test_autocommit_option_no_issue_first_connect(self):
+        eng = create_engine(testing.db.url)
+        eng.update_execution_options(autocommit=True)
+        conn = eng.connect()
+        eq_(conn._execution_options, {"autocommit": True})
+        conn.close()
+
     @testing.requires.ad_hoc_engines
     def test_generative_engine_event_dispatch_hasevents(self):
         def l1(*arg, **kw):