Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* accept unicode arrows #257

Merged
merged 1 commit into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ sbt:
- TRAVIS_PULL_REQUEST
- TRAVIS_BRANCH
- ENCRYPTION_PASSWORD
- SBT_OPTS=-Dfile.encoding=UTF-8 -Xms512m -Xmx1536m -Xss2m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the encoding issue... I have used the default options that sbt-extras is using + encoding.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.getquill.quotation

import scala.reflect.ClassTag
import scala.reflect.macros.whitebox.Context
import io.getquill.{ Query => QuillQuery }
import io.getquill.ast._
import io.getquill.norm.BetaReduction
Expand All @@ -11,7 +10,6 @@ import io.getquill.util.Interleave
trait Parsing extends SchemaConfigParsing {
this: Quotation =>

val c: Context
import c.universe.{ Ident => _, Constant => _, Function => _, If => _, _ }

case class Parser[T](p: PartialFunction[Tree, T])(implicit ct: ClassTag[T]) {
Expand Down Expand Up @@ -351,7 +349,7 @@ trait Parsing extends SchemaConfigParsing {
}

private val assignmentParser: Parser[Assignment] = Parser[Assignment] {
case q"((${ identParser(i1) }) => scala.this.Predef.ArrowAssoc[$t](${ identParser(i2) }.$prop).->[$v]($value))" if (i1 == i2) =>
case q"((${ identParser(i1) }) => scala.this.Predef.ArrowAssoc[$t](${ identParser(i2) }.$prop).$arrow[$v]($value))" if (i1 == i2) =>
Assignment(i1, prop.decodedName.toString, astParser(value))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.getquill.quotation

import io.getquill.ast.PropertyAlias
import scala.reflect.macros.whitebox.Context

case class SchemaConfig(alias: Option[String] = None, properties: List[PropertyAlias] = List(), generated: Option[String] = None)
trait SchemaConfigParsing {
val c: Context

trait SchemaConfigParsing extends UnicodeArrowParsing {
this: Quotation =>

import c.universe.{ Function => _, Ident => _, _ }

def parseEntityConfig(t: Tree): SchemaConfig =
Expand All @@ -27,7 +28,7 @@ trait SchemaConfigParsing {

private def parsePropertyAlias(t: Tree): PropertyAlias =
t match {
case q"(($x1) => scala.this.Predef.ArrowAssoc[$t]($x2.$prop).->[$v](${ alias: String }))" =>
case q"(($x1) => scala.this.Predef.ArrowAssoc[$t]($x2.$prop).$arrow[$v](${ alias: String }))" =>
PropertyAlias(prop.decodedName.toString, alias)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.getquill.quotation

trait UnicodeArrowParsing {
this: Quotation =>

import c.universe.Quasiquote

private val arrow = pq"→|->"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class QuotationSpec extends Spec {
}
quote(unquote(q)).ast mustEqual Entity("TestEntity", Some("SomeAlias"), List(PropertyAlias("s", "theS"), PropertyAlias("i", "theI")))
}
"with property alias and unicode arrow" in {
"""|quote {
| query[TestEntity](_.entity("SomeAlias").columns(_.s → "theS", _.i → "theI"))
|}
""".stripMargin must compile
}
}
"filter" in {
val q = quote {
Expand Down Expand Up @@ -267,6 +273,12 @@ class QuotationSpec extends Spec {
}
quote(unquote(q)).ast mustEqual Function(List(Ident("x1")), Update(Entity("TestEntity")))
}
"unicode arrow must compile" in {
"""|quote {
| qr1.filter(t ⇒ t.i == 1).update(_.s → "new", _.i → 0)
|}
""".stripMargin must compile
}
}
"insert" - {
"assigned" in {
Expand All @@ -281,6 +293,12 @@ class QuotationSpec extends Spec {
}
quote(unquote(q)).ast mustEqual Function(List(Ident("x1")), Insert(Entity("TestEntity")))
}
"unicode arrow must compile" in {
"""|quote {
| qr1.insert(_.s → "new", _.i → 0)
|}
""".stripMargin must compile
}
}
"delete" in {
val q = quote {
Expand Down