创建数据库生成的查询中缺少 Cassandra phantom-dsl 派生列
Cassandra phantom-dsl derived column is missing in create database generated queries
我有以下 table 定义
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"
}
具体table子class
abstract class SDST[P <: TSP[String]] extends DST[String, P, SDST[P]] {
override def tableName: String = "\"SDS\""
object entityValue extends entityValue
}
数据库class
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 生成的创建 table 查询如下所示
database.create()
c.o.phantom Executing query: CREATE TABLE IF NOT EXISTS test."SDS" (entity_key text,PRIMARY KEY (entity_key))
如您所见,创建 table DDL 时缺少派生列。
如果我在实施中遗漏了什么,请告诉我。
省略 class SDSR 和 TSP 等定义是简单的 classes。
谢谢
Phantom 目前不支持 table 到 table 继承。该决定背后的原因是我们依赖于为 DSL 提供动力的宏 API 固有的复杂性。
此功能计划在未来的版本中推出,但在此之前我们不希望它起作用,因为 table 辅助宏基本上不会读取继承的列。
我有以下 table 定义
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"
}
具体table子class
abstract class SDST[P <: TSP[String]] extends DST[String, P, SDST[P]] {
override def tableName: String = "\"SDS\""
object entityValue extends entityValue
}
数据库class
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 生成的创建 table 查询如下所示
database.create()
c.o.phantom Executing query: CREATE TABLE IF NOT EXISTS test."SDS" (entity_key text,PRIMARY KEY (entity_key))
如您所见,创建 table DDL 时缺少派生列。
如果我在实施中遗漏了什么,请告诉我。
省略 class SDSR 和 TSP 等定义是简单的 classes。
谢谢
Phantom 目前不支持 table 到 table 继承。该决定背后的原因是我们依赖于为 DSL 提供动力的宏 API 固有的复杂性。
此功能计划在未来的版本中推出,但在此之前我们不希望它起作用,因为 table 辅助宏基本上不会读取继承的列。