Following example from python cassandra driver
class Users(Model):
username = columns.Text(index=True, required=True)
user_id = columns.UUID(index=True, default=uuid.uuid4)
email = columns.Text(primary_key=True, required=True)
passwd = columns.Text()
salt = columns.Text()
And creating object in following way:
u = Users()
u.username = 'admin'
u.email = 'test@test.com'
u.password = u'test' #This is property with setter
Users.create(**dict(u))
In this case, we get user_id:None
instead of user_id:uuid.uuid4
and corresponding error.
How to make default = uuid.uuid4
work with less pain?
UPD I guess, it's caused by overriding to_database
method in UUID column. Which conflicts with base to_database
method.
UPD2 Looks like bad case. Error happens on step **dict(u)
Solution:
d = dict(u)
del d['column_with_default_value']
Users.create(**d)