Skip to content

Commit

Permalink
continue
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Feb 5, 2019
1 parent c4563a1 commit e220e7e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
22 changes: 22 additions & 0 deletions quill-sql/src/main/scala/io/getquill/MyTestSql.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.getquill

object MyTestSql {

val ctx = new SqlMirrorContext(MirrorSqlDialect, Literal)
import ctx._

case class Holder(value: String, sv: Int)

def main(args: Array[String]): Unit = {

val q = quote {
query[Holder].join(query[Holder])
.on(_.value == _.value)
.map({case (a,b) => ((a.value, a.sv), (b.value, b.sv))})
.map(_._1._2)
}

println(run(q).string)

}
}
23 changes: 23 additions & 0 deletions quill-sql/src/main/scala/io/getquill/OracleDialect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ trait OracleDialect
case other => super.sourceTokenizer.token(other)
}

override implicit def identTokenizer(implicit astTokenizer: Tokenizer[Ast], strategy: NamingStrategy): Tokenizer[Ident] =
Tokenizer[Ident](e =>
if (e.name.startsWith("_"))
Escape.default(e.name).token
else
strategy.default(e.name).token
)

override implicit def propertyTokenizer(implicit astTokenizer: Tokenizer[Ast], strategy: NamingStrategy): Tokenizer[Property] = {
Tokenizer[Property] {
case Property(ast, name) =>
unnest(ast) match {
case (ast, prefix) => {
val column = prefix.mkString + name
if (column.startsWith("_"))
stmt"${scopedTokenizer(ast)}.${Escape.column(column).token}"
else
stmt"${scopedTokenizer(ast)}.${strategy.column(column).token}"
}
}
}
}

override def prepareForProbing(string: String) = string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,21 @@ trait SqlIdiom extends Idiom {
case SetOperator.`contains` => stmt"IN"
}

implicit def propertyTokenizer(implicit astTokenizer: Tokenizer[Ast], strategy: NamingStrategy): Tokenizer[Property] = {
protected def unnest(ast: Ast): (Ast, List[String]) =
ast match {
case Property(a, name) if (name.matches("_[0-9]*")) =>
unnest(a) match {
case (ast, nestedName) =>
(ast, nestedName :+ name)
}
case Property(a, name) =>
unnest(a) match {
case (a, nestedName) => (a, nestedName)
}
case a => (a, Nil)
}

def unnest(ast: Ast): (Ast, List[String]) =
ast match {
case Property(a, name) if (name.matches("_[0-9]*")) =>
unnest(a) match {
case (ast, nestedName) =>
(ast, nestedName :+ name)
}
case Property(a, name) =>
unnest(a) match {
case (a, nestedName) => (a, nestedName)
}
case a => (a, Nil)
}
implicit def propertyTokenizer(implicit astTokenizer: Tokenizer[Ast], strategy: NamingStrategy): Tokenizer[Property] = {
Tokenizer[Property] {
case Property(ast, name) =>
unnest(ast) match {
Expand Down

0 comments on commit e220e7e

Please sign in to comment.