zio / zio-quill

Compile-time Language Integrated Queries for Scala

Home Page:https://zio.dev/zio-quill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inaccurate warning on Mapped Encodings at compile time

counter2015 opened this issue · comments

Version: 4.6.0
Module: quill-cassandra-zio
Database: cassandra

Expected behavior

import io.getquill.{CassandraZioContext, SnakeCase}
import io.getquill.CassandraZioContext.{CIO, CStream}

object AllPersistenceIds {

  object MyCassandraZioContext extends CassandraZioContext(SnakeCase)
  import MyCassandraZioContext._
  
  def all(): CStream[AllPersistenceIdsRow] = stream {
    query[AllPersistenceIdsRow]
  }

  case class AllPersistenceIdsRow(persistenceId: String)

}

It should compile well

Actual behavior

It will rasie warning in comple time

[WARNING] Questionable row-class found.
The field 'persistenceId' in the object AllPersistenceIdsRow will be used in the query instead of the field .
Are you sure this is the intended behavior? Perhaps you meant to write an encoder/decoder for AllPersistenceIdsRow?
See the section on Mapped Encodings in the quill documentation here: https://getquill.io/#extending-quill-custom-encoding for the simplest way to do that.

relative code

object BranchFoundMessage {
def makeFrom(found: BranchFound) = {
val link = "https://getquill.io/#extending-quill-custom-encoding"
// The field 'value' in Person.Name.First will be use in the query[Person] instead of Person.name or Person.Name.first.
// Are you sure this is the intended behavior? Perhaps you meant to write an encoder/decoder for Person.Name.First?
// See the section on Mapped Encodings in the quill documentation here: <> for the simplest way to do that.
val msg =
s"The field '${found.innerField}' in the object ${found.pathToInnerField} will be used in the query${found.outerClass.map(r => s"[$r]").getOrElse("")} " +
s"instead of the field ${found.possibleInnerPaths.mkString(" or ")}." +
s"\nAre you sure this is the intended behavior? " +
s"Perhaps you meant to write an encoder/decoder for ${found.pathToInnerField}?" +
s"\nSee the section on Mapped Encodings in the quill " +
s"documentation here: $link for the simplest way to do that."
BranchFoundMessage(msg)
}
}

This seems to happen on case classes with a single parameter. AllPersistenceIdsRow(persistenceId: String, test: Int) would not raise the warning, in my experience