0

我有以下对象模型:

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在本例中),但是value如果None我取消注释text_value,我将得到正确的值。

看起来db_field在子类中不受支持。这是一个错误吗?

4

0 回答 0