我有下面的表定义
import com.outworkers.phantom.builder.primitives.Primitive
import com.outworkers.phantom.dsl._
abstract class DST[V, P <: TSP[V], T <: DST[V, P, T]] extends Table[T, P] {
object entityKey extends StringColumn with PartitionKey {
override lazy val name = "entity_key"
}
abstract class entityValue(implicit ev: Primitive[V]) extends PrimitiveColumn[V] {
override lazy val name = "entity_value"
}在具体表子类中
abstract class SDST[P <: TSP[String]] extends DST[String, P, SDST[P]] {
override def tableName: String = "\"SDS\""
object entityValue extends entityValue
}数据库类
class TestDatabase(override val connector: CassandraConnection) extends Database[TestDatabase](connector) {
object SDST extends SDST[SDSR] with connector.Connector {
override def fromRow(r: Row): SDSR=
SDSR(entityKey(r), entityValue(r))
}
}由phantom-dsl生成的create table查询如下所示
database.create()
c.o.phantom Executing query: CREATE TABLE IF NOT EXISTS test."SDS" (entity_key text,PRIMARY KEY (entity_key))如您所见,create table DDL中缺少派生列。
如果我在实现中遗漏了什么,请告诉我。
省略的类定义,如SDSR和TSP,都是简单的case类。
谢谢
发布于 2018-03-01 18:56:11
Phantom目前不支持表到表的继承。这一决定背后的原因是我们所依赖的支持DSL的Macro API中固有的复杂性。
此功能计划在将来的版本中使用,但在此阶段之前,我们预计这不会起作用,因为表帮助器宏基本上不会读取继承的列。
https://stackoverflow.com/questions/48894065
复制相似问题