cur.execute("select '{postgres=arwdDxt/postgres}'::aclitem[]")
res = cur.fetchone()[0]
assert res == ["postgres=arwdDxt/postgres"]
+
+
+@pytest.mark.xfail
+def test_array_mixed_numbers():
+ # TODO: must use the type accommodating the largest/highest precision
+ tx = Transformer()
+ ad = tx.adapt([1, 32767], Format.BINARY)
+ assert ad[1] == builtins["int2"].array_oid
+ ad = tx.adapt([1, 32768], Format.BINARY)
+ assert ad[1] == builtins["int4"].array_oid
import pytest
-from psycopg3.adapt import TypeCaster, Format
+from psycopg3.adapt import TypeCaster, Transformer, Format
from psycopg3.types import builtins
from psycopg3.types.numeric import cast_float
assert cur.fetchone()[0]
+@pytest.mark.xfail
+def test_adapt_int_binary():
+ # TODO: int binary adaptation (must choose the fitting int2,4,8)
+ tx = Transformer()
+ tx.adapt(1, Format.BINARY)
+
+
@pytest.mark.parametrize(
"val, pgtype, want",
[
assert cur.fetchone()[0]
+@pytest.mark.xfail
+def test_adapt_float_binary():
+ # TODO: float binary adaptation
+ tx = Transformer()
+ tx.adapt(1.0, Format.BINARY)
+
+
@pytest.mark.parametrize(
"val, pgtype, want",
[
assert result == val
+@pytest.mark.xfail
+def test_adapt_numeric_binary():
+ # TODO: numeric binary adaptation
+ tx = Transformer()
+ tx.adapt(Decimal(1), Format.BINARY)
+
+
+@pytest.mark.xfail
+def test_cast_numeric_binary(conn):
+ # TODO: numeric binary casting
+ cur = conn.cursor(binary=True)
+ res = cur.execute("select 1::numeric").fetchone()[0]
+ assert res == Decimal(1)
+
+
@pytest.mark.parametrize(
"val",
[