summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-02-04 14:43:54 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-02-04 14:43:54 +0000
commit665e9dc665cf72086c00871756c48e8d38bade2f (patch)
tree3690755cefb299224ff9de1c934eb2bf06eb259e
parentc60682c230f8e9ef6a395be55409d549fa5d7239 (diff)
downloadpsycopg2-665e9dc665cf72086c00871756c48e8d38bade2f.tar.gz
Exposing ISOLATION_LEVEL_DEFAULT to Python
This is now the state that is returned to Python if nothing has been explicitly set.
-rw-r--r--doc/src/extensions.rst9
-rw-r--r--lib/extensions.py1
-rwxr-xr-xtests/test_connection.py2
3 files changed, 11 insertions, 1 deletions
diff --git a/doc/src/extensions.rst b/doc/src/extensions.rst
index 8d70ba3..2475d7b 100644
--- a/doc/src/extensions.rst
+++ b/doc/src/extensions.rst
@@ -651,6 +651,15 @@ set to one of the following constants:
.. __: http://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-SERIALIZABLE
+.. data:: ISOLATION_LEVEL_DEFAULT
+
+ Whatever is defined by the server, either via server configuration or by
+ statements executed within the session outside Pyscopg control; Psycopg
+ will not force an isolation level of its own. If you want to know what the
+ value is you can use a query such as :sql:`show transaction_isolation` or
+ :sql:`show default_transaction_isolation`.
+
+ .. versionadded:: 2.7
.. index::
diff --git a/lib/extensions.py b/lib/extensions.py
index b123e88..f4dc706 100644
--- a/lib/extensions.py
+++ b/lib/extensions.py
@@ -72,6 +72,7 @@ ISOLATION_LEVEL_READ_UNCOMMITTED = 4
ISOLATION_LEVEL_READ_COMMITTED = 1
ISOLATION_LEVEL_REPEATABLE_READ = 2
ISOLATION_LEVEL_SERIALIZABLE = 3
+ISOLATION_LEVEL_DEFAULT = 5
"""psycopg connection status values."""
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 15d99b4..5b304ee 100755
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -488,7 +488,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
conn = self.connect()
self.assertEqual(
conn.isolation_level,
- psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED)
+ psycopg2.extensions.ISOLATION_LEVEL_DEFAULT)
def test_encoding(self):
conn = self.connect()