@@ -100,7 +100,7 @@ class SqlServiceTest(SqlTestBase):
100
100
def test_execute (self ):
101
101
entry_count = 11
102
102
self ._populate_map (entry_count )
103
- result = self .client .sql .execute (" SELECT * FROM %s" % self .map_name )
103
+ result = self .client .sql .execute (' SELECT * FROM " %s"' % self .map_name )
104
104
six .assertCountEqual (
105
105
self ,
106
106
[(i , i ) for i in range (entry_count )],
@@ -111,7 +111,7 @@ def test_execute_with_params(self):
111
111
entry_count = 13
112
112
self ._populate_map (entry_count )
113
113
result = self .client .sql .execute (
114
- " SELECT this FROM %s WHERE __key > ? AND this > ?" % self .map_name , 5 , 6
114
+ ' SELECT this FROM "%s" WHERE __key > ? AND this > ?' % self .map_name , 5 , 6
115
115
)
116
116
six .assertCountEqual (
117
117
self ,
@@ -122,7 +122,7 @@ def test_execute_with_params(self):
122
122
def test_execute_with_mismatched_params_when_sql_has_more (self ):
123
123
self ._populate_map ()
124
124
result = self .client .sql .execute (
125
- " SELECT * FROM %s WHERE __key > ? AND this > ?" % self .map_name , 5
125
+ ' SELECT * FROM "%s" WHERE __key > ? AND this > ?' % self .map_name , 5
126
126
)
127
127
128
128
with self .assertRaises (HazelcastSqlError ):
@@ -131,7 +131,7 @@ def test_execute_with_mismatched_params_when_sql_has_more(self):
131
131
132
132
def test_execute_with_mismatched_params_when_params_has_more (self ):
133
133
self ._populate_map ()
134
- result = self .client .sql .execute (" SELECT * FROM %s WHERE this > ?" % self .map_name , 5 , 6 )
134
+ result = self .client .sql .execute (' SELECT * FROM "%s" WHERE this > ?' % self .map_name , 5 , 6 )
135
135
136
136
with self .assertRaises (HazelcastSqlError ):
137
137
for _ in result :
@@ -140,7 +140,7 @@ def test_execute_with_mismatched_params_when_params_has_more(self):
140
140
def test_execute_statement (self ):
141
141
entry_count = 12
142
142
self ._populate_map (entry_count , str )
143
- statement = SqlStatement (" SELECT this FROM %s" % self .map_name )
143
+ statement = SqlStatement (' SELECT this FROM " %s"' % self .map_name )
144
144
result = self .client .sql .execute_statement (statement )
145
145
146
146
six .assertCountEqual (
@@ -153,7 +153,7 @@ def test_execute_statement_with_params(self):
153
153
entry_count = 20
154
154
self ._populate_map (entry_count , lambda v : Student (v , v ))
155
155
statement = SqlStatement (
156
- " SELECT age FROM %s WHERE height = CAST(? AS REAL)" % self .map_name
156
+ ' SELECT age FROM "%s" WHERE height = CAST(? AS REAL)' % self .map_name
157
157
)
158
158
statement .add_parameter (13.0 )
159
159
result = self .client .sql .execute_statement (statement )
@@ -162,7 +162,7 @@ def test_execute_statement_with_params(self):
162
162
163
163
def test_execute_statement_with_mismatched_params_when_sql_has_more (self ):
164
164
self ._populate_map ()
165
- statement = SqlStatement (" SELECT * FROM %s WHERE __key > ? AND this > ?" % self .map_name )
165
+ statement = SqlStatement (' SELECT * FROM "%s" WHERE __key > ? AND this > ?' % self .map_name )
166
166
statement .parameters = [5 ]
167
167
result = self .client .sql .execute_statement (statement )
168
168
@@ -172,7 +172,7 @@ def test_execute_statement_with_mismatched_params_when_sql_has_more(self):
172
172
173
173
def test_execute_statement_with_mismatched_params_when_params_has_more (self ):
174
174
self ._populate_map ()
175
- statement = SqlStatement (" SELECT * FROM %s WHERE this > ?" % self .map_name )
175
+ statement = SqlStatement (' SELECT * FROM "%s" WHERE this > ?' % self .map_name )
176
176
statement .parameters = [5 , 6 ]
177
177
result = self .client .sql .execute_statement (statement )
178
178
@@ -183,7 +183,7 @@ def test_execute_statement_with_mismatched_params_when_params_has_more(self):
183
183
def test_execute_statement_with_timeout (self ):
184
184
entry_count = 100
185
185
self ._populate_map (entry_count , lambda v : Student (v , v ))
186
- statement = SqlStatement (" SELECT age FROM %s WHERE height < 10" % self .map_name )
186
+ statement = SqlStatement (' SELECT age FROM "%s" WHERE height < 10' % self .map_name )
187
187
statement .timeout = 100
188
188
result = self .client .sql .execute_statement (statement )
189
189
@@ -194,7 +194,7 @@ def test_execute_statement_with_timeout(self):
194
194
def test_execute_statement_with_cursor_buffer_size (self ):
195
195
entry_count = 50
196
196
self ._populate_map (entry_count , lambda v : Student (v , v ))
197
- statement = SqlStatement (" SELECT age FROM %s" % self .map_name )
197
+ statement = SqlStatement (' SELECT age FROM " %s"' % self .map_name )
198
198
statement .cursor_buffer_size = 3
199
199
result = self .client .sql .execute_statement (statement )
200
200
@@ -215,7 +215,7 @@ def test_execute_statement_with_cursor_buffer_size(self):
215
215
216
216
def test_execute_statement_with_copy (self ):
217
217
self ._populate_map ()
218
- statement = SqlStatement (" SELECT __key FROM %s WHERE this >= ?" % self .map_name )
218
+ statement = SqlStatement (' SELECT __key FROM "%s" WHERE this >= ?' % self .map_name )
219
219
statement .parameters = [9 ]
220
220
copy_statement = statement .copy ()
221
221
statement .clear_parameters ()
@@ -233,7 +233,7 @@ def test_execute_statement_with_copy(self):
233
233
def test_execute_statement_with_expected_result_type_of_rows_when_rows_are_expected (self ):
234
234
entry_count = 100
235
235
self ._populate_map (entry_count , lambda v : Student (v , v ))
236
- statement = SqlStatement (" SELECT age FROM %s WHERE age < 3" % self .map_name )
236
+ statement = SqlStatement (' SELECT age FROM "%s" WHERE age < 3' % self .map_name )
237
237
statement .expected_result_type = SqlExpectedResultType .ROWS
238
238
result = self .client .sql .execute_statement (statement )
239
239
@@ -245,7 +245,7 @@ def test_execute_statement_with_expected_result_type_of_update_count_when_rows_a
245
245
self ,
246
246
):
247
247
self ._populate_map ()
248
- statement = SqlStatement (" SELECT * FROM %s" % self .map_name )
248
+ statement = SqlStatement (' SELECT * FROM " %s"' % self .map_name )
249
249
statement .expected_result_type = SqlExpectedResultType .UPDATE_COUNT
250
250
result = self .client .sql .execute_statement (statement )
251
251
@@ -263,15 +263,15 @@ def test_execute_statement_with_expected_result_type_of_update_count_when_rows_a
263
263
class SqlResultTest (SqlTestBase ):
264
264
def test_blocking_iterator (self ):
265
265
self ._populate_map ()
266
- result = self .client .sql .execute (" SELECT __key FROM %s" % self .map_name )
266
+ result = self .client .sql .execute (' SELECT __key FROM " %s"' % self .map_name )
267
267
268
268
six .assertCountEqual (
269
269
self , [i for i in range (10 )], [row .get_object_with_index (0 ) for row in result ]
270
270
)
271
271
272
272
def test_blocking_iterator_when_iterator_requested_more_than_once (self ):
273
273
self ._populate_map ()
274
- result = self .client .sql .execute (" SELECT this FROM %s" % self .map_name )
274
+ result = self .client .sql .execute (' SELECT this FROM " %s"' % self .map_name )
275
275
276
276
six .assertCountEqual (
277
277
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):
283
283
284
284
def test_blocking_iterator_with_multi_paged_result (self ):
285
285
self ._populate_map ()
286
- statement = SqlStatement (" SELECT __key FROM %s" % self .map_name )
286
+ statement = SqlStatement (' SELECT __key FROM " %s"' % self .map_name )
287
287
statement .cursor_buffer_size = 1 # Each page will contain just 1 result
288
288
result = self .client .sql .execute_statement (statement )
289
289
@@ -293,7 +293,7 @@ def test_blocking_iterator_with_multi_paged_result(self):
293
293
294
294
def test_iterator (self ):
295
295
self ._populate_map ()
296
- result = self .client .sql .execute (" SELECT __key FROM %s" % self .map_name )
296
+ result = self .client .sql .execute (' SELECT __key FROM " %s"' % self .map_name )
297
297
298
298
iterator_future = result .iterator ()
299
299
@@ -325,7 +325,7 @@ def assertion():
325
325
326
326
def test_iterator_when_iterator_requested_more_than_once (self ):
327
327
self ._populate_map ()
328
- result = self .client .sql .execute (" SELECT this FROM %s" % self .map_name )
328
+ result = self .client .sql .execute (' SELECT this FROM " %s"' % self .map_name )
329
329
330
330
iterator = result .iterator ().result ()
331
331
@@ -344,7 +344,7 @@ def test_iterator_when_iterator_requested_more_than_once(self):
344
344
345
345
def test_iterator_with_multi_paged_result (self ):
346
346
self ._populate_map ()
347
- statement = SqlStatement (" SELECT __key FROM %s" % self .map_name )
347
+ statement = SqlStatement (' SELECT __key FROM " %s"' % self .map_name )
348
348
statement .cursor_buffer_size = 1 # Each page will contain just 1 result
349
349
result = self .client .sql .execute_statement (statement )
350
350
@@ -362,7 +362,7 @@ def test_iterator_with_multi_paged_result(self):
362
362
363
363
def test_request_blocking_iterator_after_iterator (self ):
364
364
self ._populate_map ()
365
- result = self .client .sql .execute (" SELECT * FROM %s" % self .map_name )
365
+ result = self .client .sql .execute (' SELECT * FROM " %s"' % self .map_name )
366
366
367
367
result .iterator ().result ()
368
368
@@ -372,7 +372,7 @@ def test_request_blocking_iterator_after_iterator(self):
372
372
373
373
def test_request_iterator_after_blocking_iterator (self ):
374
374
self ._populate_map ()
375
- result = self .client .sql .execute (" SELECT * FROM %s" % self .map_name )
375
+ result = self .client .sql .execute (' SELECT * FROM " %s"' % self .map_name )
376
376
377
377
for _ in result :
378
378
pass
@@ -384,19 +384,19 @@ def test_request_iterator_after_blocking_iterator(self):
384
384
# engine does not support update/insert queries now.
385
385
def test_is_row_set_when_row_is_set (self ):
386
386
self ._populate_map ()
387
- result = self .client .sql .execute (" SELECT * FROM %s" % self .map_name )
387
+ result = self .client .sql .execute (' SELECT * FROM " %s"' % self .map_name )
388
388
self .assertTrue (result .is_row_set ().result ())
389
389
390
390
# Can't test the case we would expect a non-negative updated count, because the IMDG SQL
391
391
# engine does not support update/insert queries now.
392
392
def test_update_count_when_there_is_no_update (self ):
393
393
self ._populate_map ()
394
- result = self .client .sql .execute (" SELECT * FROM %s WHERE __key > 5" % self .map_name )
394
+ result = self .client .sql .execute (' SELECT * FROM "%s" WHERE __key > 5' % self .map_name )
395
395
self .assertEqual (- 1 , result .update_count ().result ())
396
396
397
397
def test_get_row_metadata (self ):
398
398
self ._populate_map (value_factory = str )
399
- result = self .client .sql .execute (" SELECT __key, this FROM %s" % self .map_name )
399
+ result = self .client .sql .execute (' SELECT __key, this FROM " %s"' % self .map_name )
400
400
row_metadata = result .get_row_metadata ().result ()
401
401
self .assertEqual (2 , row_metadata .column_count )
402
402
columns = row_metadata .columns
@@ -407,14 +407,14 @@ def test_get_row_metadata(self):
407
407
408
408
def test_close_after_query_execution (self ):
409
409
self ._populate_map ()
410
- result = self .client .sql .execute (" SELECT * FROM %s" % self .map_name )
410
+ result = self .client .sql .execute (' SELECT * FROM " %s"' % self .map_name )
411
411
for _ in result :
412
412
pass
413
413
self .assertIsNone (result .close ().result ())
414
414
415
415
def test_close_when_query_is_active (self ):
416
416
self ._populate_map ()
417
- statement = SqlStatement (" SELECT * FROM %s " % self .map_name )
417
+ statement = SqlStatement (' SELECT * FROM "%s"' % self .map_name )
418
418
statement .cursor_buffer_size = 1 # Each page will contain 1 row
419
419
result = self .client .sql .execute_statement (statement )
420
420
@@ -430,14 +430,14 @@ def test_close_when_query_is_active(self):
430
430
431
431
def test_with_statement (self ):
432
432
self ._populate_map ()
433
- with self .client .sql .execute (" SELECT this FROM %s" % self .map_name ) as result :
433
+ with self .client .sql .execute (' SELECT this FROM " %s"' % self .map_name ) as result :
434
434
six .assertCountEqual (
435
435
self , [i for i in range (10 )], [row .get_object_with_index (0 ) for row in result ]
436
436
)
437
437
438
438
def test_with_statement_when_iteration_throws (self ):
439
439
self ._populate_map ()
440
- statement = SqlStatement (" SELECT this FROM %s" % self .map_name )
440
+ statement = SqlStatement (' SELECT this FROM " %s"' % self .map_name )
441
441
statement .cursor_buffer_size = 1 # so that it doesn't close immediately
442
442
443
443
with self .assertRaises (RuntimeError ):
@@ -582,26 +582,26 @@ def value_factory(key):
582
582
583
583
def test_null (self ):
584
584
self ._populate_map ()
585
- result = self .client .sql .execute (" SELECT __key, NULL AS this FROM %s" % self .map_name )
585
+ result = self .client .sql .execute (' SELECT __key, NULL AS this FROM " %s"' % self .map_name )
586
586
self ._validate_result (result , SqlColumnType .NULL , lambda _ : None )
587
587
588
588
def test_object (self ):
589
589
def value_factory (key ):
590
590
return Student (key , key )
591
591
592
592
self ._populate_map (value_factory = value_factory )
593
- result = self .client .sql .execute (" SELECT __key, this FROM %s" % self .map_name )
593
+ result = self .client .sql .execute (' SELECT __key, this FROM " %s"' % self .map_name )
594
594
self ._validate_result (result , SqlColumnType .OBJECT , value_factory )
595
595
596
596
def test_null_only_column (self ):
597
597
self ._populate_map ()
598
598
result = self .client .sql .execute (
599
- " SELECT __key, CAST(NULL AS INTEGER) as this FROM %s" % self .map_name
599
+ ' SELECT __key, CAST(NULL AS INTEGER) as this FROM " %s"' % self .map_name
600
600
)
601
601
self ._validate_result (result , SqlColumnType .INTEGER , lambda _ : None )
602
602
603
603
def _validate_rows (self , expected_type , value_factory = lambda key : key ):
604
- result = self .client .sql .execute (" SELECT __key, this FROM %s " % self .map_name )
604
+ result = self .client .sql .execute (' SELECT __key, this FROM "%s"' % self .map_name )
605
605
self ._validate_result (result , expected_type , value_factory )
606
606
607
607
def _validate_result (self , result , expected_type , factory ):
@@ -773,7 +773,7 @@ def test_streaming_sql_query(self):
773
773
def test_federated_query (self ):
774
774
query = (
775
775
"""
776
- CREATE MAPPING %s (
776
+ CREATE MAPPING "%s" (
777
777
__key INT,
778
778
name VARCHAR,
779
779
age INT
@@ -792,7 +792,7 @@ def test_federated_query(self):
792
792
793
793
insert_into_query = (
794
794
"""
795
- INSERT INTO %s (__key, name, age)
795
+ INSERT INTO "%s" (__key, name, age)
796
796
VALUES (1, 'John', 42)
797
797
"""
798
798
% self .map_name
0 commit comments