Skip to content

Commit

Permalink
Improve handling of raw-queries (#3147)
Browse files Browse the repository at this point in the history
* Remove codegen-tests for now since they break local-builds. Will add back in a different build or project.

* Fix build scripts. Was using bad sqlserver version.

* Better raw query support. Do not wrap top-level infixes.

* Fix Spark cases

* Another fix

* Fix another tests

* fix test
  • Loading branch information
deusaquilus authored Dec 6, 2024
1 parent 87bcdb2 commit c334986
Show file tree
Hide file tree
Showing 34 changed files with 196 additions and 1,188 deletions.
77 changes: 39 additions & 38 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ lazy val dbModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](

lazy val codegenModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-codegen`,
`quill-codegen-jdbc`,
`quill-codegen-tests`
`quill-codegen-jdbc`
)

lazy val bigdataModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
Expand Down Expand Up @@ -93,7 +92,7 @@ lazy val filteredModules = {
val moduleStrings =
ListSet(
modulesStr
.getOrElse("all")
.getOrElse("nocodegen")
.split(",")
.map(_.trim): _*
)
Expand Down Expand Up @@ -121,8 +120,10 @@ lazy val filteredModules = {
println("SBT =:> Invoking Aggregate Project")
Seq[sbt.ClasspathDep[sbt.ProjectReference]]()
case _ | "all" =>
println("SBT =:> Compiling All Modules")
allModules
println("Compiling Not-Code Generator Modules")
baseModules ++ dbModules ++ bigdataModules
// println("SBT =:> Compiling All Modules")
// allModules
}

val selectedModules = {
Expand Down Expand Up @@ -264,39 +265,39 @@ lazy val `quill-codegen-jdbc` =
.dependsOn(`quill-codegen` % "compile->compile;test->test")
.dependsOn(`quill-jdbc` % "compile->compile")

lazy val `quill-codegen-tests` =
(project in file("quill-codegen-tests"))
.settings(commonSettings: _*)
.settings(
publish / skip := true,
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % Test,
Test / fork := true,
(Test / sourceGenerators) += Def.task {
def recursiveList(file: JFile): List[JFile] =
if (file.isDirectory)
Option(file.listFiles()).map(_.flatMap(child => recursiveList(child)).toList).toList.flatten
else
List(file)
val r = (Compile / runner).value
val s = streams.value.log
val sourcePath = sourceManaged.value
val classPath = (`quill-codegen-jdbc` / Test / fullClasspath).value.map(_.data)

// We could put the code generated products directly in the `sourcePath` directory but for some reason
// intellij doesn't like it unless there's a `main` directory inside.
val fileDir = new File(sourcePath, "main").getAbsoluteFile
val dbs = Seq("testH2DB", "testMysqlDB", "testPostgresDB", "testSqliteDB", "testSqlServerDB", "testOracleDB")
println(s"Running code generation for DBs: ${dbs.mkString(", ")}")
r.run(
"io.getquill.codegen.integration.CodegenTestCaseRunner",
classPath,
fileDir.getAbsolutePath +: dbs,
s
)
recursiveList(fileDir)
}.tag(CodegenTag)
)
.dependsOn(`quill-codegen-jdbc` % "compile->test")
//lazy val `quill-codegen-tests` =
// (project in file("quill-codegen-tests"))
// .settings(commonSettings: _*)
// .settings(
// publish / skip := true,
// libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % Test,
// Test / fork := true,
// (Test / sourceGenerators) += Def.task {
// def recursiveList(file: JFile): List[JFile] =
// if (file.isDirectory)
// Option(file.listFiles()).map(_.flatMap(child => recursiveList(child)).toList).toList.flatten
// else
// List(file)
// val r = (Compile / runner).value
// val s = streams.value.log
// val sourcePath = sourceManaged.value
// val classPath = (`quill-codegen-jdbc` / Test / fullClasspath).value.map(_.data)
//
// // We could put the code generated products directly in the `sourcePath` directory but for some reason
// // intellij doesn't like it unless there's a `main` directory inside.
// val fileDir = new File(sourcePath, "main").getAbsoluteFile
// val dbs = Seq("testH2DB", "testMysqlDB", "testPostgresDB", "testSqliteDB", "testSqlServerDB", "testOracleDB")
// println(s"Running code generation for DBs: ${dbs.mkString(", ")}")
// r.run(
// "io.getquill.codegen.integration.CodegenTestCaseRunner",
// classPath,
// fileDir.getAbsolutePath +: dbs,
// s
// )
// recursiveList(fileDir)
// }.tag(CodegenTag)
// )
// .dependsOn(`quill-codegen-jdbc` % "compile->test")

val excludeTests =
sys.props.getOrElse("excludeTests", "false") match {
Expand Down
6 changes: 6 additions & 0 deletions build/Dockerfile-sqlserver
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Builds a ubuntu-based postgres image whose latency can be modified to be highe
# for performance experimentation.
FROM mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04
USER root
RUN apt-get update && \
apt-get install iproute2 iputils-ping -y
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ services:
init: true

sqlserver:
image: mcr.microsoft.com/azure-sql-edge:latest # use this because it supports ARM64 architecture for M1 Mac
build:
context: .
dockerfile: ./build/Dockerfile-sqlserver
ports:
- "11433:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=QuillRocks!
cap_add:
- NET_ADMIN

oracle:
image: quillbuilduser/oracle-18-xe-micro-sq
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit c334986

Please sign in to comment.