File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -224,12 +224,15 @@ def cql_encode_set_collection(self, val):
224
224
"""
225
225
return '{%s}' % ', ' .join (self .mapping .get (type (v ), self .cql_encode_object )(v ) for v in val )
226
226
227
- def cql_encode_all_types (self , val ):
227
+ def cql_encode_all_types (self , val , as_text_type = False ):
228
228
"""
229
229
Converts any type into a CQL string, defaulting to ``cql_encode_object``
230
230
if :attr:`~Encoder.mapping` does not contain an entry for the type.
231
231
"""
232
- return self .mapping .get (type (val ), self .cql_encode_object )(val )
232
+ encoded = self .mapping .get (type (val ), self .cql_encode_object )(val )
233
+ if as_text_type and not isinstance (encoded , six .text_type ):
234
+ return encoded .decode ('utf-8' )
235
+ return encoded
233
236
234
237
if six .PY3 :
235
238
def cql_encode_ipaddress (self , val ):
Original file line number Diff line number Diff line change @@ -1435,10 +1435,8 @@ def as_cql_query(self):
1435
1435
index_target ,
1436
1436
class_name )
1437
1437
if options :
1438
- opts_cql_encoded = _encoder .cql_encode_all_types (options )
1439
- # PYTHON-1008
1440
- if isinstance (opts_cql_encoded , six .binary_type ):
1441
- opts_cql_encoded = opts_cql_encoded .decode ('utf-8' )
1438
+ # PYTHON-1008: `ret` will always be a unicode
1439
+ opts_cql_encoded = _encoder .cql_encode_all_types (options , as_text_type = True )
1442
1440
ret += " WITH OPTIONS = %s" % opts_cql_encoded
1443
1441
return ret
1444
1442
You can’t perform that action at this time.
0 commit comments