From 26fb6d8e2d5001f5c16d361a158683e2aab467d6 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Fri, 18 Nov 2022 18:31:27 -0500 Subject: [PATCH] Disallow None in elements of array argument --- edgedb/protocol/codecs/array.pyx | 5 ++++- tests/test_async_query.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/edgedb/protocol/codecs/array.pyx b/edgedb/protocol/codecs/array.pyx index 2f709531..34cc567b 100644 --- a/edgedb/protocol/codecs/array.pyx +++ b/edgedb/protocol/codecs/array.pyx @@ -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) diff --git a/tests/test_async_query.py b/tests/test_async_query.py index af334216..e51ac197 100644 --- a/tests/test_async_query.py +++ b/tests/test_async_query.py @@ -380,6 +380,12 @@ async def test_async_args_03(self): 'combine positional and named parameters'): await self.client.query('select $0 + $bar;') + with self.assertRaisesRegex(edgedb.InvalidArgumentError, + "None is not allowed"): + await self.client.query( + "select >$0", [1, None, 3] + ) + async def test_async_args_04(self): aware_datetime = datetime.datetime.now(datetime.timezone.utc) naive_datetime = datetime.datetime.now()