]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: adapt type representation tests to crdb and postgres < 15 811/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 9 May 2024 01:49:24 +0000 (03:49 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 15 May 2024 15:56:39 +0000 (17:56 +0200)
tests/test_column.py

index d5ae58fea832b83bba9e8e25cd5d2d8c1ad3d264..f23181027c79b7df889694014339480120664624 100644 (file)
@@ -3,7 +3,7 @@ import pickle
 import pytest
 
 from psycopg.postgres import types as builtins
-from .fix_crdb import is_crdb, crdb_encoding
+from .fix_crdb import is_crdb, crdb_encoding, skip_crdb
 
 
 def test_description_attribs(conn):
@@ -62,6 +62,16 @@ def test_description_slice(conn):
     curs.description[0][0:2] == ("a", 23)
 
 
+def skip_neg_scale(*args):
+    return pytest.param(
+        *args,
+        marks=[
+            pytest.mark.crdb("skip", reason="negative precision numeric"),
+            pytest.mark.pg(">=15"),
+        ],
+    )
+
+
 @pytest.mark.parametrize(
     "type, precision, scale, dsize, isize",
     [
@@ -71,15 +81,16 @@ def test_description_slice(conn):
         ("varchar(1)", None, None, 1, None),
         ("varchar(1)[]", None, None, 1, None),
         ("varchar(42)", None, None, 42, None),
-        ("bpchar(42)", None, None, 42, None),
+        skip_crdb("bpchar(42)", None, None, 42, None, reason="bpchar"),
         ("varchar(10485760)", None, None, 10485760, None),
         ("int4", None, None, None, 4),
         ("numeric", None, None, None, None),
         ("numeric(10,0)", 10, 0, None, None),
         ("numeric(10,3)[]", 10, 3, None, None),
-        ("numeric(10,-1)", 10, -1, None, None),
-        ("numeric(1,-1000)", 1, -1000, None, None),
-        ("numeric(1,1000)", 1, 1000, None, None),
+        skip_neg_scale("numeric(2,-3)", 2, -3, None, None),
+        skip_neg_scale("numeric(3,5)", 3, 5, None, None),
+        skip_neg_scale("numeric(1,-1000)", 1, -1000, None, None),
+        skip_neg_scale("numeric(1,1000)", 1, 1000, None, None),
         ("numeric(1000,1000)", 1000, 1000, None, None),
         ("time", None, None, None, 8),
         ("time[]", None, None, None, None),
@@ -105,7 +116,8 @@ def test_details(conn, type, precision, scale, dsize, isize):
     assert col.precision == precision
     assert col.scale == scale
     assert col.display_size == dsize
-    assert col.internal_size == isize
+    if not is_crdb(conn):
+        assert col.internal_size == isize
 
 
 @pytest.mark.crdb("skip", reason="time precision")