Cassandra的Python CQLEngine模型继承

时间:2016-01-04 16:45:46

标签: python cassandra cqlengine

我有以下对象模型:

class Data(Model):
  __keyspace__ = 'varilog'
  __table_name__ = 'md_data'
  id = columns.TimeUUID(partition_key=True, primary_key=True, required=True)
  device = columns.Text(primary_key=True, required=True)
  property = columns.Text(primary_key=True, required=True)
  field = columns.Text(primary_key=True, required=True)
  cyclestamp = columns.DateTime(static=True)
  type = columns.Text(discriminator_column=True)
  #text_value = columns.Text() # Will work
  #value = columns.Text(db_field='text_value') # Will work but...

class DataText(Data):
  __discriminator_value__ = 'str'
  value = columns.Text(db_field='text_value') # Always None
  #text_value = columns.Text() # Ok also

当我查询对象时,根据type列的值,返回正确的对象(在此示例中为DataText),但是valueNone text_value如果我取消注释db_field,我将获得正确的值。

看起来子类中不支持exitValue()。这是一个错误吗?

0 个答案:

没有答案