case class Person(name: String)
and case class Row(owner: Person)
the field name would be owner_name
Hi all,
I'm trying to refactor the following dynamic query into a compile-time version:
val query = if (fetchingForward)
quote {
filterBy(criteria).sortBy(_.id)(Ord.desc)
}
else
quote {
filterBy(criteria).sortBy(_.id)(Ord.asc)
}
I was trying the following:
val sortOrder: Ord[Int] = if (fetchingForward) Ord.desc else Ord.asc
val query = quote {
filterBy(criteria).sortBy(_.id)(lift(sortOrder))
}
However, I'm getting the exception during macro expansion
error. Any suggestion on how I can fix this? Cheers.
MappedEncoding
imported but it appears to be ignored (as it would be mapping to an ISO string but is still mapped to what looks like an epoch second in stead). Is there any extra configuration to override the dencoders for those types that Quill is already aware of?
Hello,
what is the current recommendation about what async context to use with Quill 3.6.0 for PostgreSQL and with Scala 2.13?
There are some alternatives, but
is there any way to reuse querySchema definitions. for example
case class Person(name: String, age: Int) extends Embedded
case class Unit(stuff:Int,person:Person)
val q = quote{querySchema[Person]("table",
_.name-> "NAMED",_.age->"MyAge")}
val m = ctx.run(query[Unit].filter(p => p.person.name == "John"))
I would like to be able to use the schema defined for Person in the query defined for Unit either through implicits or combining 2 querySchemas
Table case class is
case class DailyOrgActivity(
orgId: UUID,
date: String,
nuggetId: UUID,
userId: String)
want to filter between startTime and endTime which are both org.joda.time.Datetime
how to do that in easy and effectibve way.
Right now I am getting a List(string ) between these two dates and using.filter(activity => liftQuery(inDatesChunk).contains(activity.date))
but it is not a good way.
interface
with all the methods you need, returning java types and collections, and implement this interface in Scala using Quill. This should be possible.
Hi everyone :-)
Noticed right now that quill is sensitive to the order or parameters, constructing a case class via apply method in a quote {}
block and using named parameters.
If I change the order of the parameters the code doesn't compile anymore giving:
Found the following free variables: IdentName(x2), IdentName(x1), IdentName(x5), IdentName(x3), IdentName(x6), IdentName(x4), IdentName(x7).
Quotations can't reference values outside their scope directly.
In order to bind runtime values to a quotation, please use the method `lift`.
Example: `def byName(n: String) = quote(query[Person].filter(_.name == lift(n)))`
.run(quote {
Is it a known problem?
Take this ammonite script:
import $ivy.`io.getquill::quill-sql:3.6.0`
import io.getquill._
case class Foo(
a: Int,
b: String
)
case class Bar(
a: Int,
b: String
)
val ctx = new SqlMirrorContext(MirrorSqlDialect, SnakeCase)
import ctx._
ctx.run(quote {
for {
foo <- query[Foo]
} yield Bar(b = foo.b, a = foo.a)
})
If you change Bar(b = foo.b, a = foo.a)
with Bar(a = foo.a, b = foo.b)
it works!
querySchema("Foo").map(foo => CaseClass(a: x2, b: x1))