Skip to content

Commit

Permalink
Allow enums in array codec
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed May 26, 2023
1 parent 03e4012 commit 2de7e3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion edgedb/protocol/codecs/array.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cdef class BaseArrayCodec(BaseCodec):

if not isinstance(
self.sub_codec,
(ScalarCodec, TupleCodec, NamedTupleCodec, RangeCodec)
(ScalarCodec, TupleCodec, NamedTupleCodec, RangeCodec, EnumCodec)
):
raise TypeError(
'only arrays of scalars are supported (got type {!r})'.format(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,12 @@ async def test_enum_03(self):
c_red = await self.client.query_single('SELECT <Color>"red"')
c_red2 = await self.client.query_single('SELECT <Color>$0', c_red)
self.assertIs(c_red, c_red2)

async def test_enum_04(self):
enums = await self.client.query_single(
'SELECT <array<Color>>$0', ['red', 'white']
)
enums2 = await self.client.query_single(
'SELECT <array<Color>>$0', enums
)
self.assertEqual(enums, enums2)

0 comments on commit 2de7e3f

Please sign in to comment.