Skip to content

Commit 6eaceb0

Browse files
Moktofruch
authored andcommitted
Allow extra field when inserting with prepared queries
Let's say you have a message: ``` class Address(object): def __init__(self, street, zipcode, **kwargs): self.street = street self.zipcode = zipcode cluster.register_user_type('mykeyspace', 'address', Address) ``` And let's say the type actually contains another field, let's call i `raw_address` Then inserting data through a prepared statement will actually fail : the driver will complain `raw_address` is missing. This change addresses that, as any field should be optional.
1 parent 00329a3 commit 6eaceb0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cassandra/cqltypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ def serialize_safe(cls, val, protocol_version):
10261026
try:
10271027
item = val[i]
10281028
except TypeError:
1029-
item = getattr(val, fieldname)
1029+
item = getattr(val, fieldname, None)
10301030

10311031
if item is not None:
10321032
packed_item = subtype.to_binary(item, proto_version)

0 commit comments

Comments
 (0)