]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added get_execution_options for Engine and Connectino 4465/head
authorDaniel Lister <dan.lister@gmail.com>
Thu, 24 Jan 2019 18:25:03 +0000 (13:25 -0500)
committerDaniel Lister <dan.lister@gmail.com>
Thu, 24 Jan 2019 18:25:03 +0000 (13:25 -0500)
lib/sqlalchemy/engine/base.py
test/engine/test_execute.py

index 64303f29058169cdf32d6f75e2e4a1b974ffe077..6fbe177d24436e71d24622ae045dac950120ad82 100644 (file)
@@ -332,6 +332,15 @@ class Connection(Connectable):
         self.dialect.set_connection_execution_options(c, opt)
         return c
 
+    def get_execution_options(self):
+        """ Get the non-SQL options which will take effect during execution.
+
+        .. seealso::
+
+            :meth:`.Connection.execution_options`
+        """
+        return self._execution_options
+
     @property
     def closed(self):
         """Return True if this connection is closed."""
@@ -1935,6 +1944,15 @@ class Engine(Connectable, log.Identified):
         """
         return OptionEngine(self, opt)
 
+    def get_execution_options(self):
+        """ Get the non-SQL options which will take effect during execution.
+
+        .. seealso::
+
+            :meth:`.Engine.execution_options`
+        """
+        return self._execution_options
+
     @property
     def name(self):
         """String name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
index 061dae005788d967e1abeff69f523e68af3f0098..ad9144a382ed1561ab1fef9ea97ab2b6d493e234 100644 (file)
@@ -1272,6 +1272,21 @@ class ExecutionOptionsTest(fixtures.TestBase):
         c2_branch = c2.connect()
         eq_(c2_branch._execution_options, {"foo": "bar"})
 
+    def test_get_engine_execution_options(self):
+        engine = testing_engine("sqlite://")
+        engine.dialect = Mock()
+        e2 = engine.execution_options(foo="bar")
+
+        eq_(e2.get_execution_options(), {"foo": "bar"})
+
+    def test_get_connection_execution_options(self):
+        engine = testing_engine("sqlite://", options=dict(_initialize=False))
+        engine.dialect = Mock()
+        conn = engine.connect()
+        c = conn.execution_options(foo="bar")
+
+        eq_(c.get_execution_options(), {"foo": "bar"})
+
 
 class EngineEventsTest(fixtures.TestBase):
     __requires__ = ("ad_hoc_engines",)