Questions tagged [quill.io]

A library that allows you to write queries in Scala with QDSL (Quoted Domain Specific Language). The queries then get executed in the query language of your choice (SQL, CQL, etc.).

Quill provides a Quoted Domain Specific Language (QDSL) to express queries in Scala and execute them in a target language. The library’s core is designed to support multiple target languages, currently featuring specializations for and .

  1. Boilerplate-free mapping. The database schema is mapped using simple case classes.
  2. Quoted DSL. Queries are defined inside a quote block. Quill parses each quoted block of code (quotation) at compile time and translates them to an internal Abstract Syntax Tree (AST)
  3. Compile-time query generation. The Context.run call reads the quotation’s AST and translates it to the target language at compile time, emitting the query string as a compilation message. As the query string is known at compile time, the runtime overhead is very low and similar to using the database driver directly.
  4. Compile-time query validation. If configured, the query is verified against the database at compile time and the compilation fails if it is not valid. The query validation does not alter the database state.

Resources:

41 questions
8
votes
1 answer

How to define table name at runtime using quill

Im new at quill and im trying to define a table at runtime, but im getting a compilation error. Is there any workaround for this ? or its just impossible using quill ? The code example is : case class ExampleCaseClass(id : String, version :…
oron
  • 133
  • 8
4
votes
1 answer

SQL `NULL` read at column 1 (JDBC type null) but mapping is to a non-Option type

I want select the max value using this query (all fields in table are not null): dc.run(quote { query[SchemaInfo] .filter(_.subjectName == lift(subject)) .map(_.version) .max }).map(_.map(_ + 1).getOrElse(1)) I know, that…
Nikita Ryanov
  • 1,520
  • 3
  • 17
  • 34
4
votes
2 answers

Can't find an implicit `SchemaMeta` for type

I wrote this simple application using Quill library to query Cassandra QuillSample.scala import java.util.UUID import io.getquill._ import scala.concurrent.ExecutionContext.Implicits.global object QuillSample extends App { lazy val ctx = new…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
3
votes
1 answer

Scala: what can code in Context.eval reference?

It seems that the input of Context.eval can reference only values from different compilation unit: // project 1 object Z { val foo = "WOOF" def impl(c: Context)(x: c.Expr[String]) = { val x1 =…
Ford O.
  • 1,394
  • 8
  • 25
3
votes
1 answer

what schema evolution should I use while using quill-async-mysql and play 2.6?

Im using quill-async-mysql in my project, and I have a simple db setup in my application.conf: quilldb { host = 127.0.0.1 port = 3306 user = root password = "" database = MyDatabaseName } thats it. And now I want to add some kind of…
3
votes
3 answers

How to write generic function with Scala Quill.io library

I am trying to implement generic method in Scala operating on database using Quill.io library. Type T will be only case classes what works with Quill.io. def insertOrUpdate[T](inserting: T, equality: (T,T) => Boolean)(implicit ctx: Db.Context): Unit…
snilard
  • 97
  • 2
  • 7
2
votes
0 answers

Order by in Quill SQL produces Subquery

I have an employee class. case class Employee(name: String, age: Int, company: String) and I write a Group-By query in Quill. val q = quote { query[Employee] .filter(_.age == lift(100)) .groupBy(_.company) .map { a => val…
user9920500
  • 606
  • 7
  • 21
2
votes
1 answer

How to batch insert with quill dynamic queries?

I'm trying to use Quill dynamic queries to perform batch insert In non-dynamic api I would've used: db.run(quote { liftQuery(myCollection).foreach(data => querySchema[MyDBClass]("table").insert(data)) }) I've tried doing the same for dynamic…
mich8bsp
  • 325
  • 1
  • 3
  • 9
2
votes
1 answer

Quill onconflictupdate multiple values

Is it in quill somehow possible to update multiple values on a conflict? E.g like this: val a = quote { query[Product] .insert(_.id -> 1, _.sku -> 10) .onConflictUpdate((t, e) => t.sku -> (t.sku + e.sku), t.abc -> e.abc) } I tried it like…
Syrius
  • 941
  • 6
  • 22
2
votes
1 answer

`exception during macro expansion: [error] scala.reflect.macros.TypecheckException` when using quill

I'm pretty new to Scala, Play, and Quill and I'm not sure what I'm doing wrong. I have my project split up into models, repositories, and services (and controllers, but that is not relevant for this question). Right now, I'm getting this error for…
jmkoni
  • 463
  • 4
  • 14
2
votes
3 answers

Failing to use transactions in Quill to INSERT one-to-many relational objects

I have a person table and animal table and in the animal table there is FK to personId since there is one-to-many relation between them. I just want to create a person and create its animals using a transaction cause I want the process to be atomic…
MNY
  • 1,506
  • 5
  • 21
  • 34
2
votes
1 answer

how to translate update set SQL to scala quill?

I have a schema in PostgreSql in which I want do update set for users_id field: CREATE TABLE if not exists rooms ( oid char(24), owner_id char(24) not null, users_id text[], PRIMARY KEY (oid) ); The execute sql as this: update rooms set…
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
1
vote
1 answer

How do I filter Nones out of a column of options?

I thought this would work to extract a List[String], but no. (anmKey is Option[String]) run(query[Anm].map(_.anmKey).flatMap(_))
user3416742
  • 168
  • 1
  • 1
  • 7
1
vote
0 answers

Get children of a OneToMany relationship

With Ebean, you can access a OneToMany relationship with an accessor. What is the best way to do this in Quill ? Is there a way to do it with the "for-comprehension" syntax ? Should that be handled in classic scala groupBy, afterwards ? Here is a…
Julien D
  • 1,259
  • 9
  • 22
1
vote
0 answers

Concatenate more than one Infixes in Quill SQL

I have to write plain SQL queries inside infixes. I have a main SQL query and then add AND clauses into it based on certain conditions. For example : val andClause= quote { (name: String) => infix"""AND name = $name """.as[Query[(Int,…
user9920500
  • 606
  • 7
  • 21
1
2 3