if format == Format.AUTO:
# When dumping a string with %s we may refer to any type actually,
# but the user surely passed a text format
- if cls is str:
+ if issubclass(cls, str):
dmaps = [self._dumpers[pq.Format.TEXT]]
else:
dmaps = [
cur = conn.cursor()
cur.execute("select %s", [MyStr("hello")])
- assert cur.fetchone() == ("hellob",)
+ assert cur.fetchone() == ("hellot",)
cur.execute("select %t", [MyStr("hello")])
assert cur.fetchone() == ("hellot",)
cur.execute("select %b", [MyStr("hello")])
make_bin_dumper("bc").register(str, cur)
cur.execute("select %s", [MyStr("hello")])
- assert cur.fetchone() == ("hellobc",)
+ assert cur.fetchone() == ("hellotc",)
cur.execute("select %t", [MyStr("hello")])
assert cur.fetchone() == ("hellotc",)
cur.execute("select %b", [MyStr("hello")])
cur = conn.cursor()
cur.execute("select %s", [MyStr("hello")])
- assert cur.fetchone() == ("hellob",)
+ assert cur.fetchone() == ("hellot",)
cur.execute("select %t", [MyStr("hello")])
assert cur.fetchone() == ("hellot",)
cur.execute("select %b", [MyStr("hello")])
cur.execute(f"select %{fmt_in}", ("\uddf8",))
-@pytest.mark.parametrize("fmt_in", [Format.AUTO, Format.TEXT, Format.BINARY])
+@pytest.mark.parametrize("fmt_in", [Format.AUTO, Format.TEXT])
def test_dump_enum(conn, fmt_in):
from enum import Enum
class MyEnum(str, Enum):
foo = "foo"
+ bar = "bar"
cur = conn.cursor()
- (res,) = cur.execute("select %s", (MyEnum.foo,)).fetchone()
+ cur.execute("create type myenum as enum ('foo', 'bar')")
+ cur.execute("create table with_enum (e myenum)")
+ cur.execute(f"insert into with_enum (e) values (%{fmt_in})", (MyEnum.foo,))
+ (res,) = cur.execute("select e from with_enum").fetchone()
assert res == "foo"