Skip to content

Commit

Permalink
Disallow None in elements of array argument
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Nov 23, 2022
1 parent a2bec18 commit 26fb6d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion edgedb/protocol/codecs/array.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ cdef class BaseArrayCodec(BaseCodec):
for i in range(objlen):
item = obj[i]
if item is None:
elem_data.write_int32(-1)
raise ValueError(
"invalid array element at index {}: "
"None is not allowed".format(i)
)
else:
try:
self.sub_codec.encode(elem_data, item)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ async def test_async_args_03(self):
'combine positional and named parameters'):
await self.client.query('select <int64>$0 + <int64>$bar;')

with self.assertRaisesRegex(edgedb.InvalidArgumentError,
"None is not allowed"):
await self.client.query(
"select <array<int64>>$0", [1, None, 3]
)

async def test_async_args_04(self):
aware_datetime = datetime.datetime.now(datetime.timezone.utc)
naive_datetime = datetime.datetime.now()
Expand Down

0 comments on commit 26fb6d8

Please sign in to comment.