Skip to content

Commit

Permalink
Fix #2709: SQL Server top statement doesn't use parenthesis.
Browse files Browse the repository at this point in the history
  • Loading branch information
lprieur-drevon-ncl committed Mar 1, 2023
1 parent c33ac29 commit aacfacf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -37,7 +37,7 @@ trait SQLServerDialect

override protected def limitOffsetToken(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
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 aacfacf

Please sign in to comment.