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

Embedded Scala case classes are not translated to CQL queries #3125

Open
tashoyan opened this issue Oct 29, 2024 · 0 comments
Open

Embedded Scala case classes are not translated to CQL queries #3125

tashoyan opened this issue Oct 29, 2024 · 0 comments

Comments

@tashoyan
Copy link

This template isn't a strict requirement to open issues, but please try to provide as much information as possible.

Version: ZIO Quill 4.8.4
Module: quill-cassandra
Database: Cassandra

Expected behavior

As described in the chapter Embedded case classes:

Scala classes to describe Cassandra DB entities:

final case class Contact(phone: String, address: String)
final case class Person(id: Int, name: String, contact: Contact)

DAO to retrieve Persons from Cassandra DB:

class PersonDao(implicit ctx: CassandraAsyncContext[SnakeCase]) {
  import ctx._

  def retrievePersons: Future[List[Person]] = {
    ctx.run(query[Person])
  }

}

Expected CQL query:

SELECT x.id, x.name, x.phone, x.address FROM Person x

Actual behavior

Actual CQL query generated:

SELECT id, name, contact FROM person

The query contains a wrong column contact. Instead it should contain attributes of the embedded case class Contact: phone and address.

I tried to add extends Embedded but this doesn't help.

Steps to reproduce the behavior

Take the example documented in Embedded case classes and try to compile and run it. When compiling, the compiler prints the generated query on stdio.

Workaround

Don't use embedded case classes for database queries, use additional flat case classes instead. This is quite inconvenient and requires to write additional transformations between the two formats.

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

1 participant