mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 09:06:41 +03:00
Bug fix - parse_array fails on int arrays
This commit is contained in:
parent
66f8e8a4ae
commit
685e3dffe9
|
@ -73,8 +73,8 @@ def parse_array(array_string):
|
|||
else:
|
||||
# Start of non-quoted value, find its end
|
||||
match = re.search(r",|\]", array_string)
|
||||
values.append(array_string[1 : match.start() + 1])
|
||||
array_string = array_string[match.end():]
|
||||
values.append(array_string[0 : match.start()])
|
||||
array_string = array_string[match.end() - 1:]
|
||||
|
||||
|
||||
def import_submodules(package_name):
|
||||
|
|
|
@ -46,6 +46,21 @@ class ArrayFieldsTest(unittest.TestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
instance.arr_int = value
|
||||
|
||||
def test_parse_array(self):
|
||||
from infi.clickhouse_orm.utils import parse_array, unescape
|
||||
self.assertEquals(parse_array("[]"), [])
|
||||
self.assertEquals(parse_array("[1, 2, 395, -44]"), ["1", "2", "395", "-44"])
|
||||
self.assertEquals(parse_array("['big','mouse','','!']"), ["big", "mouse", "", "!"])
|
||||
self.assertEquals(parse_array(unescape("['\\r\\n\\0\\t\\b']")), ["\r\n\0\t\b"])
|
||||
for s in ("",
|
||||
"[",
|
||||
"]",
|
||||
"[1, 2",
|
||||
"3, 4]",
|
||||
"['aaa', 'aaa]"):
|
||||
with self.assertRaises(ValueError):
|
||||
parse_array(s)
|
||||
|
||||
|
||||
class ModelWithArrays(Model):
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user