我有以下表定义
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)是简单的案例类。
谢谢
Phantom目前不支持表到表的继承。这一决定背后的原因是我们依靠为DSL供电的Macro API固有的复杂性。
此功能计划在将来的版本中使用,但在此阶段之前我们不希望这样做,因为表助手宏不会读取基本上继承的列。