Skip to content

Commit

Permalink
Fix tuple state prefix read/write #372
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Apr 18, 2023
1 parent 494e009 commit 43b8af1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clickhouse_driver/columns/tuplecolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def read_data(self, n_items, buf):
def read_items(self, n_items, buf):
return self.read_data(n_items, buf)

def read_state_prefix(self, buf):
for x in self.nested_columns:
x.read_state_prefix(buf)

def write_state_prefix(self, buf):
for x in self.nested_columns:
x.write_state_prefix(buf)


def create_tuple_column(spec, column_by_spec_getter, column_options):
inner_spec = get_inner_spec('Tuple', spec)
Expand Down
19 changes: 19 additions & 0 deletions tests/columns/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,22 @@ def test_type_mismatch_error(self):
with self.create_table(columns):
with self.assertRaises(errors.TypeMismatchError):
self.client.execute('INSERT INTO test (a) VALUES', data)

def test_tuple_of_low_cardinality(self):
data = [((1, 2), )]
columns = 'a Tuple(LowCardinality(Int32), LowCardinality(Int32))'

with self.create_table(columns):
self.client.execute(
'INSERT INTO test (a) VALUES', data
)

query = 'SELECT * FROM test'
inserted = self.emit_cli(query)
self.assertEqual(
inserted,
'(1,2)\n'
)

inserted = self.client.execute(query)
self.assertEqual(inserted, data)

0 comments on commit 43b8af1

Please sign in to comment.