summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-20 15:01:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-20 15:04:31 -0500
commitdda5c43cab88daad02bc871cf40bf4984e94a031 (patch)
tree86e3a5badb675598445df085cb5430dae499c882 /test/dialect/postgresql
parentc6b15e443e0cfc7a09eb24c37123a595fdb639ca (diff)
downloadsqlalchemy-dda5c43cab88daad02bc871cf40bf4984e94a031.tar.gz
restore empty list logic to ARRAY of ENUM parsing
Fixed regression where the change in :ticket:`7148` to repair ENUM handling in PostgreSQL broke the use case of an empty ARRAY of ENUM, preventing rows that contained an empty array from being handled correctly when fetching results. Fixes: #7590 Change-Id: I43a35ef25281a6e0a26b698efebef6ba12a63e8c
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_types.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index 991b0ed9d..0c00c7633 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -1911,7 +1911,7 @@ class ArrayRoundTripTest:
t.drop(connection)
eq_(inspect(connection).get_enums(), [])
- def _type_combinations(exclude_json=False):
+ def _type_combinations(exclude_json=False, exclude_empty_lists=False):
def str_values(x):
return ["one", "two: %s" % x, "three", "four", "five"]
@@ -1945,6 +1945,9 @@ class ArrayRoundTripTest:
AnEnum.Foo,
]
+ def empty_list(x):
+ return []
+
class inet_str(str):
def __eq__(self, other):
return str(self) == str(other)
@@ -2078,6 +2081,15 @@ class ArrayRoundTripTest:
),
]
+ if not exclude_empty_lists:
+ elements.extend(
+ [
+ (postgresql.ENUM(AnEnum), empty_list),
+ (sqltypes.Enum(AnEnum, native_enum=True), empty_list),
+ (sqltypes.Enum(AnEnum, native_enum=False), empty_list),
+ (postgresql.ENUM(AnEnum, native_enum=True), empty_list),
+ ]
+ )
if not exclude_json:
elements.extend(
[
@@ -2166,7 +2178,7 @@ class ArrayRoundTripTest:
connection.scalar(select(table.c.bar).where(table.c.id == 2)),
)
- @_type_combinations()
+ @_type_combinations(exclude_empty_lists=True)
def test_type_specific_slice_update(
self, type_specific_fixture, connection, type_, gen
):
@@ -2193,7 +2205,7 @@ class ArrayRoundTripTest:
eq_(rows, [(gen(1),), (sliced_gen,)])
- @_type_combinations(exclude_json=True)
+ @_type_combinations(exclude_json=True, exclude_empty_lists=True)
def test_type_specific_value_delete(
self, type_specific_fixture, connection, type_, gen
):