【发布时间】:2018-03-01 18:56:11
【问题描述】:
我有以下表格定义
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 生成的创建表查询如下所示
database.create()
c.o.phantom Executing query: CREATE TABLE IF NOT EXISTS test."SDS" (entity_key text,PRIMARY KEY (entity_key))
如您所见,创建表 DDL 中缺少派生列。
如果我在实施中遗漏了什么,请告诉我。
省略的类定义,如 SDSR 和 TSP 是简单的案例类。
谢谢
【问题讨论】:
标签: cassandra cassandra-3.0 phantom-dsl