Skip to content

Commit 219f266

Browse files
committed
(improvement) remove protocol_version where possible
In most of the cases, it is simply not needed. For the very few cases it is, kept it. I think it simplifies the code. Signed-off-by: Yaniv Kaul <[email protected]>
1 parent 20c696e commit 219f266

21 files changed

+405
-490
lines changed

cassandra/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4714,7 +4714,7 @@ def _set_result(self, host, connection, pool, response):
47144714
protocol = self.session.cluster.protocol_version
47154715
info = self._custom_payload.get('tablets-routing-v1')
47164716
ctype = types.lookup_casstype('TupleType(LongType, LongType, ListType(TupleType(UUIDType, Int32Type)))')
4717-
tablet_routing_info = ctype.from_binary(info, protocol)
4717+
tablet_routing_info = ctype(protocol).from_binary(info)
47184718
first_token = tablet_routing_info[0]
47194719
last_token = tablet_routing_info[1]
47204720
tablet_replicas = tablet_routing_info[2]

cassandra/column_encryption/_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def encode_and_encrypt(self, coldesc, obj):
114114
coldata = self.coldata.get(coldesc)
115115
if not coldata:
116116
raise ValueError("Could not find ColData for ColDesc %s".format(coldesc))
117-
return self.encrypt(coldesc, coldata.type.serialize(obj, None))
117+
return self.encrypt(coldesc, coldata.type(None).serialize(obj))
118118

119119
def cache_info(self):
120120
return AES256ColumnEncryptionPolicy._build_cipher.cache_info()

cassandra/cqlengine/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ def _transform_column(col_name, col_obj):
948948
key_cols = [c for c in partition_keys.values()]
949949
partition_key_index = dict((col.db_field_name, col._partition_key_index) for col in key_cols)
950950
key_cql_types = [c.cql_type for c in key_cols]
951-
key_serializer = staticmethod(lambda parts, proto_version: [t.to_binary(p, proto_version) for t, p in zip(key_cql_types, parts)])
951+
key_serializer = staticmethod(lambda parts, proto_version: [t(proto_version).to_binary(p) for t, p in zip(key_cql_types, parts)])
952952
else:
953953
partition_key_index = {}
954954
key_serializer = staticmethod(lambda parts, proto_version: None)

0 commit comments

Comments
 (0)