Created
July 23, 2019 05:22
-
-
Save deusaquilus/b3abd822e2ff02f0acfd776b903ff372 to your computer and use it in GitHub Desktop.
Get Back a Broken Quill SQL Query (i.e. Skip Query Verification)
This file contains 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
import io.getquill._ | |
import io.getquill.context.sql.norm._ | |
import io.getquill.norm.capture.AvoidCapture | |
import io.getquill.ast._ | |
import io.getquill.norm._ | |
import io.getquill.context.sql._ | |
import scala.annotation.tailrec | |
import io.getquill.context.sql.idiom.VerifySqlQuery | |
import io.getquill.norm.capture.DemarcateExternalAliases | |
case class PersonId(pid:Int) | |
case class Person(id: Int, name: String, age: Int) | |
case class Membership(personId: Int, team: Int) | |
// need exact type here since implicit resolution doesn't seem to walk across variance hiearachy | |
// usually implicits with work with parametricity. I'm not sure why they dont in this case sto sto | |
implicit val naming:NamingStrategy = Literal // Needed for tokenizer | |
object TestIdiom extends MirrorSqlDialect { override def prepareForProbing(string: String): String = null } | |
import TestIdiom._ | |
implicit val tokenizer = TestIdiom.defaultTokenizer | |
val ctx = new SqlMirrorContext(MirrorSqlDialect, Literal) | |
import ctx._ | |
val q = quote { | |
... // Your query here | |
} | |
// Depending on various circumstances, you might need to do this again. | |
// implicit val naming:NamingStrategy = Literal | |
TestIdiom.sqlQueryTokenizer.token(ExpandNestedQueries(SqlQuery(SqlNormalize(q.ast)), collection.Set.empty)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment