This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolvers ++= Seq( | |
("OSS-Snapshots" at "https://oss.sonatype.org/service/local/repositories/snapshots/content/") | |
) | |
libraryDependencies ++= Seq( | |
"io.getquill" %% "quill-sql" % "3.5.3-SNAPSHOT", | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Address(street: String, zip: Int, personName: String) | |
case class Person(name: String, addresses: List[String]) | |
/* | |
In some Data-Models used with Spark, you may want to embed arrays into an object. | |
You may then want to be able to set array-properties of this kind of object when | |
a group-by is done. Normally this would be done in Spark using the following way | |
*/ | |
val addresses: Dataset[Address] = ??? | |
val people = addresses.groupByKey(a => a.personName).mapGroups { case (name, addresses) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
group=$1 | |
artifact=$2 | |
version=$3 | |
# Diff like this: | |
# diff <(search_maven_gav.sh io.getquill 'quill-*_2.13' 3.6.0-RC2 | awk '{print $2}' | sort) <(search_maven_gav.sh io.getquill 'quill-*_2.13' 3.6.0-RC3 | awk '{print $2}' | sort) | |
curl -s "https://search.maven.org/solrsearch/select?rows=100&q=g:${group}+AND+a:${artifact}+AND+v:${version}" | jq --raw-output '.response.docs[] | [.g, .a, .v]|@tsv' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Provide a single Environment Has clause: | |
// ZLayer[Orig, E, Has[From] with Rest] => ZLayer[Orig, E, Has[To] with Rest] | |
def projectionWithEffect[From: Tag, To: Tag, Rest <: Has[_]: Tag, E](effect: (From, Rest) => IO[E, To]): ZLayer[Has[From] with Rest, E, Has[To] with Rest] = | |
(for { | |
from <- ZIO.service[From] | |
rest <- ZIO.environment[Rest] | |
result <- effect(from, rest) | |
} yield Has(result) ++ rest).toLayerMany |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.getquill.context.jasync | |
import com.github.jasync.sql.db.pool.ConnectionPool | |
import com.github.jasync.sql.db.{ ConcreteConnection, Connection, QueryResult, RowData } | |
import io.getquill.context.sql.SqlContext | |
import io.getquill.context.sql.idiom.SqlIdiom | |
import io.getquill.context.{ Context, TranslateContext } | |
import io.getquill.monad.ScalaFutureIOMonad | |
import io.getquill.util.ContextLogger | |
import io.getquill.{ NamingStrategy, ReturnAction } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I first found this in PeopleSpec that was being used by PeoplePostgresAsyncSpec | |
trait PeopleSpec extends Spec { | |
inline def peopleInsert = | |
quote((p: Person) => query[Person].insert(p)) | |
inline def couplesInsert = | |
quote((c: Couple) => query[Couple].insert(c)) | |
} | |
// Then this stuff was used in PeoplePostgresAsyncSpec | |
class PeoplePostgresAsyncSpec extends PeopleSpec { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It's a bit complex because if you throw an error you usually don't get the result | |
// i.e. the place where the decoder is summoned returns the error because no decoder can be summoned from there | |
// [error] -- Error: /Users/aleiof/git/dotty_test/quill-sql/src/test/scala/io/getquill/QueryTest.scala:31:26 | |
// [error] 31 | val result = ctx.run(q) | |
// [error] | ^^^^^^^^^^ | |
// [error] | Decoder could not be summoned during query execution | |
// if you use report.warning and return something you usually get it | |
def decode[T: Type, ResultRow: Type](index: Expr[Int], resultRow: Expr[ResultRow])(using Quotes): Expr[T] = { | |
import quotes.reflect._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.getquill.context.sql | |
import java.time.LocalDate | |
import java.util.{ Date, UUID } | |
import io.getquill.context.Context | |
import io.getquill._ | |
//case class EncodingTestType(value: String) | |
case class Number(value: String) extends AnyVal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Say we have something like this: | |
case class OperationsParser(root: Parser[Ast] = Parser.empty)(override implicit val qctx: Quotes) extends Parser.Clause[Ast] with ComparisonTechniques { | |
def delegate: PartialFunction[Expr[_], Ast] = { | |
case ... | |
} | |
} | |
// Just do this: | |
case class OperationsParser(root: Parser[Ast] = Parser.empty)(override implicit val qctx: Quotes) extends Parser.Clause[Ast] with ComparisonTechniques { | |
def delegate: PartialFunction[Expr[_], Ast] = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.getquill.util | |
import io.getquill.AstPrinter | |
import fansi.Str | |
import io.getquill.ast.Renameable.{ ByStrategy, Fixed } | |
import io.getquill.ast.Visibility.{ Hidden, Visible } | |
import io.getquill.ast._ | |
import io.getquill.quat.Quat | |
import io.getquill.util.Messages.QuatTrace | |
import pprint.{ Renderer, Tree, Truncated } |