From dcf20cd2ba32c12b77606ca8bcc2d73eb0848ac0 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Thu, 9 Nov 2017 13:00:29 -0500 Subject: [PATCH] Add spanner system tests: - Write / read back null string. - Write / read back empty array of string. - Write / read back null array of string. - Write / read back array of string with mixed null / non-null values. Toward #4364. --- spanner/tests/_fixtures.py | 5 +++++ spanner/tests/system/test_system.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/spanner/tests/_fixtures.py b/spanner/tests/_fixtures.py index d2345750b8210..fe7e038b88468 100644 --- a/spanner/tests/_fixtures.py +++ b/spanner/tests/_fixtures.py @@ -42,6 +42,11 @@ name STRING(1024), value INT64 ) PRIMARY KEY (name); +CREATE TABLE string_plus_array_of_string ( + id INT64, + name STRING(16), + tags ARRAY ) + PRIMARY KEY (id); """ DDL_STATEMENTS = [stmt.strip() for stmt in DDL.split(';') if stmt.strip()] diff --git a/spanner/tests/system/test_system.py b/spanner/tests/system/test_system.py index f255237cd14b7..34c29bb3e3bc0 100644 --- a/spanner/tests/system/test_system.py +++ b/spanner/tests/system/test_system.py @@ -452,6 +452,30 @@ def test_batch_insert_then_read(self): rows = list(snapshot.read(self.TABLE, self.COLUMNS, self.ALL)) self._check_row_data(rows) + def test_batch_insert_then_read_string_array_of_string(self): + TABLE = 'string_plus_array_of_string' + COLUMNS = ['id', 'name', 'tags'] + ROWDATA = [ + (0, None, None), + (1, 'phred', ['yabba', 'dabba', 'do']), + (2, 'bharney', []), + (3, 'wylma', ['oh', None, 'phred']), + ] + retry = RetryInstanceState(_has_all_ddl) + retry(self._db.reload)() + + session = self._db.session() + session.create() + self.to_delete.append(session) + + with session.batch() as batch: + batch.delete(TABLE, self.ALL) + batch.insert(TABLE, COLUMNS, ROWDATA) + + snapshot = session.snapshot(read_timestamp=batch.committed) + rows = list(snapshot.read(TABLE, COLUMNS, self.ALL)) + self._check_row_data(rows, expected=ROWDATA) + def test_batch_insert_then_read_all_datatypes(self): retry = RetryInstanceState(_has_all_ddl) retry(self._db.reload)()