]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Use constant name as return value for pipeline_status
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 10 Oct 2021 19:59:05 +0000 (21:59 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 10 Oct 2021 19:59:05 +0000 (21:59 +0200)
Also use the enum in test, without assuming OFF == 0

psycopg_c/psycopg_c/pq/pgconn.pyx
tests/pq/test_pipeline.py

index fe23ebb3f60f3a25faa418e4fe8611f50be4340e..6c9039d84b57027ce02bc93eb25c225440eeb42a 100644 (file)
@@ -543,7 +543,7 @@ cdef class PGconn:
         For libpq < 14.0, always return 0 (PQ_PIPELINE_OFF).
         """
         if libpq.PG_VERSION_NUM < 140000:
-            return 0
+            return libpq.PQ_PIPELINE_OFF
         cdef int status = libpq.PQpipelineStatus(self._pgconn_ptr)
         return status
 
index 438aae3e7a16d330236076a008a92070d6160b80..a19333a951e808ee45521fd1d492f3d91f2f6da9 100644 (file)
@@ -18,7 +18,7 @@ def test_old_libpq(pgconn):
 @pytest.mark.libpq(">= 14")
 def test_work_in_progress(pgconn):
     assert not pgconn.nonblocking
-    assert not pgconn.pipeline_status
+    assert pgconn.pipeline_status == pq.PipelineStatus.OFF
     pgconn.enter_pipeline_mode()
     pgconn.send_query_params(b"select $1", [b"1"])
     with pytest.raises(
@@ -29,7 +29,7 @@ def test_work_in_progress(pgconn):
 
 @pytest.mark.libpq(">= 14")
 def test_multi_pipelines(pgconn):
-    assert not pgconn.pipeline_status
+    assert pgconn.pipeline_status == pq.PipelineStatus.OFF
     pgconn.enter_pipeline_mode()
     pgconn.send_query_params(b"select $1", [b"1"])
     pgconn.pipeline_sync()
@@ -83,7 +83,7 @@ def table(pgconn):
 
 @pytest.mark.libpq(">= 14")
 def test_pipeline_abort(pgconn, table):
-    assert not pgconn.pipeline_status
+    assert pgconn.pipeline_status == pq.PipelineStatus.OFF
     pgconn.enter_pipeline_mode()
     pgconn.send_query_params(b"insert into pipeline values ($1)", [b"1"])
     pgconn.send_query_params(b"select no_such_function($1)", [b"1"])