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

Support for Mixed Lifting #2563

Closed
deusaquilus opened this issue Aug 8, 2022 · 1 comment · Fixed by #2571
Closed

Support for Mixed Lifting #2563

deusaquilus opened this issue Aug 8, 2022 · 1 comment · Fixed by #2571

Comments

@deusaquilus
Copy link
Collaborator

Quill does not support combining entity-column lifts coming from liftQuery with regular lifts:

  val ctx = new SqlMirrorContext(PostgresDialect, Literal)
  import ctx._
  case class Person(id: Int, name: String, age: Int)
  val people = List(Person(1, "A", 111), Person(2, "B", 222), Person(3, "C", 333), Person(4, "D", 444), Person(5, "E", 555))
  val result = ctx.run(liftQuery(people).foreach(p => 
    query[Person].insert(
      _.id -> p.id, 
      _.name -> (lift("foo") + p.name), 
      _.age -> p.age
    )
   )
  )

Yields this:

BatchActionMirror(
  List(
    (
      "INSERT INTO Person (id,name,age) VALUES (?, (? || ?), ?)",
      List(
        Row(List(1, "foo", "A", 111)),
        Row(List(2, "foo", "B", 222)),
        Row(List(3, "foo", "C", 333)),
        Row(List(4, "foo", "D", 444)),
        Row(List(5, "foo", "E", 555))
      )
    )
  ),
  io.getquill.context.ExecutionInfo@7d45e754
)

How now in the BatchActionMirror, lifts for the "foo" are missing.

As was discovered in ProtoQuill, actually doing entity-column lifts together with regular lifts requires writing a LiftsOrderer component to re-order the lifts but in Scala2-Quill where lifts are stored directly in the Tree (instead of just being associated via ScalarTag/QuotationTag like in ProtoQuill) this kind of functionality is very difficult to do (hence is not supported).

As a consequence of this, Mixed-Lifting will likely not be supported in Quill, even lift VALUES-clause batch lifting is implemented and this will be a known missing edge-case.

@deusaquilus
Copy link
Collaborator Author

Actually, this is fixed by #2571.

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

Successfully merging a pull request may close this issue.

1 participant