Skip to content

Commit

Permalink
fix #419
Browse files Browse the repository at this point in the history
  • Loading branch information
tminglei committed Jul 11, 2018
1 parent 868f366 commit 672b4ec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,12 @@ object PgTokenHelper {
}
}
// mark + escape + mark
case Marker(m) if ((tokens(i-1) == Comma || tokens(i-1).isInstanceOf[Open])
&& (tokens(i+1) == Comma || tokens(i+1).isInstanceOf[Close])) => {
case t @ Marker(m) if ((tokens(i-1) == Comma || tokens(i-1).isInstanceOf[Open])
&& (tokens(i+1) == Comma || tokens(i+1).isInstanceOf[Close])) => {
val topMarker = stack.top.border.marker
if ((m.length > topMarker.length * 2) && m.startsWith(topMarker) && m.endsWith(topMarker)) {
if (topMarker == "") {
stack.push(WorkingGroup(t, stack.top.level +1))
} else if ((m.length > topMarker.length * 2) && m.startsWith(topMarker) && m.endsWith(topMarker)) {
stack.top.tokens += Escape(m.substring(topMarker.length -1, m.length -topMarker.length))
} else stack.top.tokens += Escape(m)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.tminglei.slickpg.utils

import org.scalatest.FunSuite

class SimpleArrayUtilsSuite extends FunSuite {

test("fromString") {
val v1 = SimpleArrayUtils.fromString(identity)("""{)}""")
assert(v1 === Some(Seq(")")))

val v2 = SimpleArrayUtils.fromString(identity)("""{"prefix)"}""")
assert(v2 === Some(Seq("prefix)")))

val v3 = SimpleArrayUtils.fromString(identity)("""{")"}""")
assert(v3 === Some(Seq(")")))

val v4 = SimpleArrayUtils.fromString(identity)("""{"other",")"}""")
assert(v4 === Some(Seq("other", ")")))

val v5 = SimpleArrayUtils.fromString(identity)("""{")suffix"}""")
assert(v5 === Some(Seq(")suffix")))
}
}

0 comments on commit 672b4ec

Please sign in to comment.