I'm using Phantom DSL (v2.28.0, scala v2.12.7) and upon each query to my database I receive the following ambiguous error:
scala.NotImplementedError: an implementation is missing
This doesn't happen when I use .future()
to resolve my query, in that case queries work just fine. Also, running a .executableQuery()
method returns a properly formatted query, which all points to my failure to build a model properly, but I don't get it what I'm doing wrong. Example queries:
Working queries:
db.entries.select.all.future // -> Returns a Future[ResultSet]
db.entries.select.where(_.user_id is userId).future() // -> ^
Failing queries:
db.entries.select.all.fetch // -> Err
db.entries.select.where(_.user_id is userId).fetch() // -> Err
db.entries.select.all.fetchRecord // -> Err
...
The same goes for paginateRecord() etc.
case class Rec(
id: UUID,
body: String,
time: DateTime,
user_id: Integer
)
abstract class active extends Table[active, Rec] {
object id extends UUIDColumn with PartitionKey
object body extends StringColumn
object time extends DateTimeColumn
object user_id extends IntColumn
}
class BasicDatabase(override val connector: CassandraConnection) extends Database[BasicDatabase](connector) {
object entries extends active with Connector
}
implicit val keySpace: KeySpace = KeySpace("some_keyspace")
implicit val session: Session = db.session
object db extends BasicDatabase(CassandraConnector.default)
I'm still a newbie so any suggestions are useful, thanks in advance.
Alright, after digging into the source code, I figured out that the fromRow()
method of the abstract class was failing so I added an override:
abstract class active extends Table[active, Rec] {
object id extends TimeUUIDColumn
object body extends StringColumn
object time extends DateTimeColumn
object user_id extends IntColumn
override def fromRow(row: Row): Rec = Rec(id(row), body(row), time(row), user_id(row))
}
This fixed the issue albeit I'm still not sure as to why it was failing in the first case, so any answer with appropriate explanation is still welcome.