From: Daniele Varrazzo Date: Thu, 5 May 2022 21:04:10 +0000 (+0200) Subject: test: add test to verify the wrong array oid with numbers X-Git-Tag: 3.1~117^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e08604191b7764db38276c1d2961a58d3d003bf;p=thirdparty%2Fpsycopg.git test: add test to verify the wrong array oid with numbers The array binary dumper does the right thing; the text one picks numeric[] unconditionally. It was clearly made on purpose, but #293 shows that it's a bad idea. --- diff --git a/tests/types/test_array.py b/tests/types/test_array.py index eeacd1bc8..a0b27c3c3 100644 --- a/tests/types/test_array.py +++ b/tests/types/test_array.py @@ -139,10 +139,25 @@ def test_array_of_unknown_builtin(conn): assert res[1] == [val] -@pytest.mark.parametrize("array, type", [([1, 32767], "int2"), ([1, 32768], "int4")]) -def test_array_mixed_numbers(array, type): +@pytest.mark.parametrize( + "array, type", + [ + ([0], "int2"), + ([1, 2**15 - 1], "int2"), + ([1, -(2**15)], "int2"), + ([1, 2**15], "int4"), + ([1, 2**31 - 1], "int4"), + ([1, -(2**31)], "int4"), + ([1, 2**31], "int8"), + ([1, 2**63 - 1], "int8"), + ([1, -(2**63)], "int8"), + ([1, 2**63], "numeric"), + ], +) +@pytest.mark.parametrize("fmt_in", PyFormat) +def test_numbers_array(array, type, fmt_in): tx = Transformer() - dumper = tx.get_dumper(array, PyFormat.BINARY) + dumper = tx.get_dumper(array, fmt_in) dumper.dump(array) assert dumper.oid == builtins[type].array_oid