Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate warning on Mapped Encodings at compile time #2639

Open
counter2015 opened this issue Nov 2, 2022 · 1 comment
Open

Inaccurate warning on Mapped Encodings at compile time #2639

counter2015 opened this issue Nov 2, 2022 · 1 comment

Comments

@counter2015
Copy link
Contributor

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)
}
}

@counter2015 counter2015 changed the title Inaccurate waring on Mapped Encodings on compile time Inaccurate waring on Mapped Encodings at compile time Nov 2, 2022
@JakobBruenker
Copy link

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

@counter2015 counter2015 changed the title Inaccurate waring on Mapped Encodings at compile time Inaccurate warning on Mapped Encodings at compile time Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants