【问题标题】:Cassandra phantom-dsl derived column is missing in create database generated queries创建数据库生成的查询中缺少 Cassandra phantom-dsl 派生列
【发布时间】: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


    【解决方案1】:

    Phantom 目前不支持表到表继承。该决定背后的原因是我们依赖于为 DSL 提供支持的 Macro API 中固有的复杂性。

    此功能计划在未来的版本中使用,但在此之前,我们预计此功能不会起作用,因为表格辅助宏基本上不会读取继承的列。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 2016-04-10
      • 2015-05-12
      • 2021-06-06
      • 2021-10-18
      相关资源
      最近更新 更多