-
Notifications
You must be signed in to change notification settings - Fork 33
MS SQL - take 3 #94
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
MS SQL - take 3 #94
Conversation
Use `SELECT TOP(?) ...` for MS SQL when there's no offset.
The built-in LogMessageWaitStrategy doesn't work.
MSSQL does not support EXCLUDE in window functions
…' when IDENTITY_INSERT is set to OFF" adds a prequery param to TestChecker so we can call SET IDENTITY_INSERT buyer ON before the query
…peMappers for java.util.Date/LocalDateTime/Instant defined in MsSqlDialect.scala
This is to ensure that both possible values of boolean are tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. Thanks for finishing up the PR.
Back when I was working on this the biggest problem was handling Boolean. I also thought of having a marker to differentiate Boolean in different types of clauses, e.g. WHERE
vs SELECT
, like what you've done here. My concern at that time was subqueries, e.g. a WHERE
clause with a SELECT
subquery that returns Boolean. However I couldn't think of a specific query/use case where such a clause would be useful or cannot be rewritten in a better way.
.filter(_ => Expr(true))
would fail with MSSQL, but the clause itself is useless, and would even be optimized away if rewritten as.filter(_ => true)
.- Another query that I think would also probably fail is
Buyer.select.filter(c => Buyer.select.map(c => c.id `=` 3).sortBy(c => c).desc.take(1).toExpr)
(I haven't actually run this yet), but it's also not practical.
This is the kind of select
inside where
subquery that is actually practical, which is already handled correctly.
test("subqueryInFilter") - checker( |
Thus I agree with the handling of Boolean done in this PR.
Thanks @kiendang @aldum I think this looks good overall. Could you flesh out the PR description:
Also add comments in the relevant places in the code
|
Thanks for looking at it, @jtjeferreira, @kiendang, @lihaoyi ! I will move this comment into the description and reword a bit. The requested comments were added in the commits above. |
@aldum I think this looks great, thanks for your work. For the bounty, @kiendang has already received 500USD for his work earlier, and I'll split the remaining 1000USD bounty between @aldum and @jtjeferreira at 500USD each since all of you contributed significantly to the final PR @aldum @jtjeferreira do email me your international bank transfer credentials and I will close out the bounty |
This PR builds on the work in #29 and #60 by @kiendang and @jtjeferreira.
What it does:
main
DataTypesTests
andOptionalsTests
with the point of contention being the lack of a dedicated boolean column typeHow this is achieved:
T-SQL (the dialect used by MS SQL Server) does have
Boolean
s as part of filter expressions, but not as column data, withBIT
s being used as a substitute. Hence, these uses which are bothBoolean
on the Scala side, need to be distinguished. To this end, a marker was introduced inContext
, explicitly designatingInsertValues
,InsertSelect
,InsertColumns
andUpdate
expression as using them as values. This was done globally, because overloading would lead to a lot more boilerplate, while simply disregarding the flags value leave the existing dialects intact.Known omissions:
ExprBooleanOps
forBIT
values: small edge case, it's possible and there's syntax for it (bitwise operators), but it needs another branching of the above kind, to not break the normal OR/AND/NOT syntax. Bitwise operators are also already tested as part of NumericOps.Dialect
trait yet, which would indicate this more cleanly,