diff --git a/tests/integration/backward_compatible/sql_test.py b/tests/integration/backward_compatible/sql_test.py index 2b5e27aba9..668a9fd545 100644 --- a/tests/integration/backward_compatible/sql_test.py +++ b/tests/integration/backward_compatible/sql_test.py @@ -100,7 +100,7 @@ class SqlServiceTest(SqlTestBase): def test_execute(self): entry_count = 11 self._populate_map(entry_count) - result = self.client.sql.execute("SELECT * FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT * FROM "%s"' % self.map_name) six.assertCountEqual( self, [(i, i) for i in range(entry_count)], @@ -111,7 +111,7 @@ def test_execute_with_params(self): entry_count = 13 self._populate_map(entry_count) result = self.client.sql.execute( - "SELECT this FROM %s WHERE __key > ? AND this > ?" % self.map_name, 5, 6 + 'SELECT this FROM "%s" WHERE __key > ? AND this > ?' % self.map_name, 5, 6 ) six.assertCountEqual( self, @@ -122,7 +122,7 @@ def test_execute_with_params(self): def test_execute_with_mismatched_params_when_sql_has_more(self): self._populate_map() result = self.client.sql.execute( - "SELECT * FROM %s WHERE __key > ? AND this > ?" % self.map_name, 5 + 'SELECT * FROM "%s" WHERE __key > ? AND this > ?' % self.map_name, 5 ) with self.assertRaises(HazelcastSqlError): @@ -131,7 +131,7 @@ def test_execute_with_mismatched_params_when_sql_has_more(self): def test_execute_with_mismatched_params_when_params_has_more(self): self._populate_map() - result = self.client.sql.execute("SELECT * FROM %s WHERE this > ?" % self.map_name, 5, 6) + result = self.client.sql.execute('SELECT * FROM "%s" WHERE this > ?' % self.map_name, 5, 6) with self.assertRaises(HazelcastSqlError): for _ in result: @@ -140,7 +140,7 @@ def test_execute_with_mismatched_params_when_params_has_more(self): def test_execute_statement(self): entry_count = 12 self._populate_map(entry_count, str) - statement = SqlStatement("SELECT this FROM %s" % self.map_name) + statement = SqlStatement('SELECT this FROM "%s"' % self.map_name) result = self.client.sql.execute_statement(statement) six.assertCountEqual( @@ -153,7 +153,7 @@ def test_execute_statement_with_params(self): entry_count = 20 self._populate_map(entry_count, lambda v: Student(v, v)) statement = SqlStatement( - "SELECT age FROM %s WHERE height = CAST(? AS REAL)" % self.map_name + 'SELECT age FROM "%s" WHERE height = CAST(? AS REAL)' % self.map_name ) statement.add_parameter(13.0) result = self.client.sql.execute_statement(statement) @@ -162,7 +162,7 @@ def test_execute_statement_with_params(self): def test_execute_statement_with_mismatched_params_when_sql_has_more(self): self._populate_map() - statement = SqlStatement("SELECT * FROM %s WHERE __key > ? AND this > ?" % self.map_name) + statement = SqlStatement('SELECT * FROM "%s" WHERE __key > ? AND this > ?' % self.map_name) statement.parameters = [5] result = self.client.sql.execute_statement(statement) @@ -172,7 +172,7 @@ def test_execute_statement_with_mismatched_params_when_sql_has_more(self): def test_execute_statement_with_mismatched_params_when_params_has_more(self): self._populate_map() - statement = SqlStatement("SELECT * FROM %s WHERE this > ?" % self.map_name) + statement = SqlStatement('SELECT * FROM "%s" WHERE this > ?' % self.map_name) statement.parameters = [5, 6] result = self.client.sql.execute_statement(statement) @@ -183,7 +183,7 @@ def test_execute_statement_with_mismatched_params_when_params_has_more(self): def test_execute_statement_with_timeout(self): entry_count = 100 self._populate_map(entry_count, lambda v: Student(v, v)) - statement = SqlStatement("SELECT age FROM %s WHERE height < 10" % self.map_name) + statement = SqlStatement('SELECT age FROM "%s" WHERE height < 10' % self.map_name) statement.timeout = 100 result = self.client.sql.execute_statement(statement) @@ -194,7 +194,7 @@ def test_execute_statement_with_timeout(self): def test_execute_statement_with_cursor_buffer_size(self): entry_count = 50 self._populate_map(entry_count, lambda v: Student(v, v)) - statement = SqlStatement("SELECT age FROM %s" % self.map_name) + statement = SqlStatement('SELECT age FROM "%s"' % self.map_name) statement.cursor_buffer_size = 3 result = self.client.sql.execute_statement(statement) @@ -215,7 +215,7 @@ def test_execute_statement_with_cursor_buffer_size(self): def test_execute_statement_with_copy(self): self._populate_map() - statement = SqlStatement("SELECT __key FROM %s WHERE this >= ?" % self.map_name) + statement = SqlStatement('SELECT __key FROM "%s" WHERE this >= ?' % self.map_name) statement.parameters = [9] copy_statement = statement.copy() statement.clear_parameters() @@ -233,7 +233,7 @@ def test_execute_statement_with_copy(self): def test_execute_statement_with_expected_result_type_of_rows_when_rows_are_expected(self): entry_count = 100 self._populate_map(entry_count, lambda v: Student(v, v)) - statement = SqlStatement("SELECT age FROM %s WHERE age < 3" % self.map_name) + statement = SqlStatement('SELECT age FROM "%s" WHERE age < 3' % self.map_name) statement.expected_result_type = SqlExpectedResultType.ROWS result = self.client.sql.execute_statement(statement) @@ -245,7 +245,7 @@ def test_execute_statement_with_expected_result_type_of_update_count_when_rows_a self, ): self._populate_map() - statement = SqlStatement("SELECT * FROM %s" % self.map_name) + statement = SqlStatement('SELECT * FROM "%s"' % self.map_name) statement.expected_result_type = SqlExpectedResultType.UPDATE_COUNT result = self.client.sql.execute_statement(statement) @@ -263,7 +263,7 @@ def test_execute_statement_with_expected_result_type_of_update_count_when_rows_a class SqlResultTest(SqlTestBase): def test_blocking_iterator(self): self._populate_map() - result = self.client.sql.execute("SELECT __key FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT __key FROM "%s"' % self.map_name) six.assertCountEqual( self, [i for i in range(10)], [row.get_object_with_index(0) for row in result] @@ -271,7 +271,7 @@ def test_blocking_iterator(self): def test_blocking_iterator_when_iterator_requested_more_than_once(self): self._populate_map() - result = self.client.sql.execute("SELECT this FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT this FROM "%s"' % self.map_name) six.assertCountEqual( self, [i for i in range(10)], [row.get_object_with_index(0) for row in result] @@ -283,7 +283,7 @@ def test_blocking_iterator_when_iterator_requested_more_than_once(self): def test_blocking_iterator_with_multi_paged_result(self): self._populate_map() - statement = SqlStatement("SELECT __key FROM %s" % self.map_name) + statement = SqlStatement('SELECT __key FROM "%s"' % self.map_name) statement.cursor_buffer_size = 1 # Each page will contain just 1 result result = self.client.sql.execute_statement(statement) @@ -293,7 +293,7 @@ def test_blocking_iterator_with_multi_paged_result(self): def test_iterator(self): self._populate_map() - result = self.client.sql.execute("SELECT __key FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT __key FROM "%s"' % self.map_name) iterator_future = result.iterator() @@ -325,7 +325,7 @@ def assertion(): def test_iterator_when_iterator_requested_more_than_once(self): self._populate_map() - result = self.client.sql.execute("SELECT this FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT this FROM "%s"' % self.map_name) iterator = result.iterator().result() @@ -344,7 +344,7 @@ def test_iterator_when_iterator_requested_more_than_once(self): def test_iterator_with_multi_paged_result(self): self._populate_map() - statement = SqlStatement("SELECT __key FROM %s" % self.map_name) + statement = SqlStatement('SELECT __key FROM "%s"' % self.map_name) statement.cursor_buffer_size = 1 # Each page will contain just 1 result result = self.client.sql.execute_statement(statement) @@ -362,7 +362,7 @@ def test_iterator_with_multi_paged_result(self): def test_request_blocking_iterator_after_iterator(self): self._populate_map() - result = self.client.sql.execute("SELECT * FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT * FROM "%s"' % self.map_name) result.iterator().result() @@ -372,7 +372,7 @@ def test_request_blocking_iterator_after_iterator(self): def test_request_iterator_after_blocking_iterator(self): self._populate_map() - result = self.client.sql.execute("SELECT * FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT * FROM "%s"' % self.map_name) for _ in result: pass @@ -384,19 +384,19 @@ def test_request_iterator_after_blocking_iterator(self): # engine does not support update/insert queries now. def test_is_row_set_when_row_is_set(self): self._populate_map() - result = self.client.sql.execute("SELECT * FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT * FROM "%s"' % self.map_name) self.assertTrue(result.is_row_set().result()) # Can't test the case we would expect a non-negative updated count, because the IMDG SQL # engine does not support update/insert queries now. def test_update_count_when_there_is_no_update(self): self._populate_map() - result = self.client.sql.execute("SELECT * FROM %s WHERE __key > 5" % self.map_name) + result = self.client.sql.execute('SELECT * FROM "%s" WHERE __key > 5' % self.map_name) self.assertEqual(-1, result.update_count().result()) def test_get_row_metadata(self): self._populate_map(value_factory=str) - result = self.client.sql.execute("SELECT __key, this FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT __key, this FROM "%s"' % self.map_name) row_metadata = result.get_row_metadata().result() self.assertEqual(2, row_metadata.column_count) columns = row_metadata.columns @@ -407,14 +407,14 @@ def test_get_row_metadata(self): def test_close_after_query_execution(self): self._populate_map() - result = self.client.sql.execute("SELECT * FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT * FROM "%s"' % self.map_name) for _ in result: pass self.assertIsNone(result.close().result()) def test_close_when_query_is_active(self): self._populate_map() - statement = SqlStatement("SELECT * FROM %s " % self.map_name) + statement = SqlStatement('SELECT * FROM "%s"' % self.map_name) statement.cursor_buffer_size = 1 # Each page will contain 1 row result = self.client.sql.execute_statement(statement) @@ -430,14 +430,14 @@ def test_close_when_query_is_active(self): def test_with_statement(self): self._populate_map() - with self.client.sql.execute("SELECT this FROM %s" % self.map_name) as result: + with self.client.sql.execute('SELECT this FROM "%s"' % self.map_name) as result: six.assertCountEqual( self, [i for i in range(10)], [row.get_object_with_index(0) for row in result] ) def test_with_statement_when_iteration_throws(self): self._populate_map() - statement = SqlStatement("SELECT this FROM %s" % self.map_name) + statement = SqlStatement('SELECT this FROM "%s"' % self.map_name) statement.cursor_buffer_size = 1 # so that it doesn't close immediately with self.assertRaises(RuntimeError): @@ -582,7 +582,7 @@ def value_factory(key): def test_null(self): self._populate_map() - result = self.client.sql.execute("SELECT __key, NULL AS this FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT __key, NULL AS this FROM "%s"' % self.map_name) self._validate_result(result, SqlColumnType.NULL, lambda _: None) def test_object(self): @@ -590,18 +590,18 @@ def value_factory(key): return Student(key, key) self._populate_map(value_factory=value_factory) - result = self.client.sql.execute("SELECT __key, this FROM %s" % self.map_name) + result = self.client.sql.execute('SELECT __key, this FROM "%s"' % self.map_name) self._validate_result(result, SqlColumnType.OBJECT, value_factory) def test_null_only_column(self): self._populate_map() result = self.client.sql.execute( - "SELECT __key, CAST(NULL AS INTEGER) as this FROM %s" % self.map_name + 'SELECT __key, CAST(NULL AS INTEGER) as this FROM "%s"' % self.map_name ) self._validate_result(result, SqlColumnType.INTEGER, lambda _: None) def _validate_rows(self, expected_type, value_factory=lambda key: key): - result = self.client.sql.execute("SELECT __key, this FROM %s " % self.map_name) + result = self.client.sql.execute('SELECT __key, this FROM "%s"' % self.map_name) self._validate_result(result, expected_type, value_factory) def _validate_result(self, result, expected_type, factory): @@ -773,7 +773,7 @@ def test_streaming_sql_query(self): def test_federated_query(self): query = ( """ - CREATE MAPPING %s ( + CREATE MAPPING "%s" ( __key INT, name VARCHAR, age INT @@ -792,7 +792,7 @@ def test_federated_query(self): insert_into_query = ( """ - INSERT INTO %s (__key, name, age) + INSERT INTO "%s" (__key, name, age) VALUES (1, 'John', 42) """ % self.map_name