Skip to content

Commit

Permalink
Fix zio#2709: SQL Server top statement doesn't use parenthesis. (zio#…
Browse files Browse the repository at this point in the history
…2710)

Co-authored-by: Juliano Alves <von.juliano@gmail.com>
  • Loading branch information
2 people authored and joelsonoda committed Jun 27, 2023
1 parent cc7ecb1 commit 29aabcf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait SQLServerDialect
query: Statement
)(implicit astTokenizer: Tokenizer[Ast], strategy: NamingStrategy) =
Tokenizer[(Option[Ast], Option[Ast])] {
case (Some(limit), None) => stmt"TOP ${limit.token} $query"
case (Some(limit), None) => stmt"TOP (${limit.token}) $query"
case (Some(limit), Some(offset)) => stmt"$query OFFSET ${offset.token} ROWS FETCH FIRST ${limit.token} ROWS ONLY"
case (None, Some(offset)) => stmt"$query OFFSET ${offset.token} ROWS"
case other => super.limitOffsetToken(query).token(other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SQLServerDialectSpec extends Spec {
qr1.take(15).map(t => t.i)
}
ctx.run(q).string mustEqual
"SELECT TOP 15 t.i FROM TestEntity t"
"SELECT TOP (15) t.i FROM TestEntity t"
}

"literal booleans" - {
Expand Down

0 comments on commit 29aabcf

Please sign in to comment.