Skip to content

Commit

Permalink
Make parentheses-for-union-queries specific to MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
kuppuswamy committed Jun 19, 2017
1 parent aeb7bb7 commit c9c6dd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -424,9 +424,9 @@ trait JdbcStatementBuilderComponent { self: JdbcProfile =>
b"\}" b"\}"
case Union(left, right, all) => case Union(left, right, all) =>
b"\{" b"\{"
buildFrom(left, None, false) buildFrom(left, None, true)
if(all) b"\nunion all " else b"\nunion " if(all) b"\nunion all " else b"\nunion "
buildFrom(right, None, false) buildFrom(right, None, true)
b"\}" b"\}"
case SimpleLiteral(w) => b += w case SimpleLiteral(w) => b += w
case s: SimpleExpression => s.toSQL(this) case s: SimpleExpression => s.toSQL(this)
Expand Down
6 changes: 6 additions & 0 deletions slick/src/main/scala/slick/jdbc/MySQLProfile.scala
Expand Up @@ -186,6 +186,12 @@ trait MySQLProfile extends JdbcProfile { profile =>
case RowNum(sym, true) => b"(@`$sym := @`$sym + 1)" case RowNum(sym, true) => b"(@`$sym := @`$sym + 1)"
case RowNum(sym, false) => b"@`$sym" case RowNum(sym, false) => b"@`$sym"
case RowNumGen(sym, init) => b"@`$sym := $init" case RowNumGen(sym, init) => b"@`$sym := $init"
case Union(left, right, all) =>
b"\{"
buildFrom(left, None, false)
if(all) b"\nunion all " else b"\nunion "
buildFrom(right, None, false)
b"\}"
case _ => super.expr(n, skipParens) case _ => super.expr(n, skipParens)
} }


Expand Down

0 comments on commit c9c6dd0

Please sign in to comment.