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

Let SQL Server top statement use parenthesis #2710

Merged
merged 2 commits into from May 31, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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