-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add support for Microsoft SQL (take2) #60
base: main
Are you sure you want to change the base?
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
nice work @jtjeferreira , looks like we may be reaching the finish line! |
I forgot to push yesterday commits 🤦 . Can you run CI again? |
@jtjeferreira done |
…e mssql does not support sorting on aliases
I fixed/ignored a few more tests and only 2 tests are failing:
|
@lihaoyi I noticed
which triggers the error My suspicion is that this due to different implementation of |
…peMappers for java.util.Date/LocalDateTime/Instant defined in MsSqlDialect.scala
9adf9d9
to
ba91db2
Compare
only 2 more failures. Seems like we're almost there!
|
scalasql/core/src/DbApi.scala
Outdated
// TODO - is this necessary? Not all jdbc drivers support releaseSavepoint (MsSql) | ||
// connection.releaseSavepoint(savepoint) |
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.
@lihaoyi what do you think about this?
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.
If the underlying JDBC driver doesn't support it, there's nothing we can do, and we can just conditionally disable that line. But we should make sure we understand and document what the consequences are: does SqlServer not support savepoints at all? Or can you create them but not release them? So what does that mean for users?
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.
I don't have any hints haha, Scala 3 support was contributed by @mrdziuban a while back. Maybe he has some ideas, but if not we'll have to investigate this and ourselves and figure out what's going on
Here are my (unsolicited) thoughts,
- The common expectation is that savepoint-related resources be released after savepoint delineation. Thus, I'd argue for this behavior to be default. (Even SQLite supports releasing savepoints :)
- My research also confirms that SQLServer doesn't support
releaseSavepoint()
. As such, we should only conditionally callreleaseSavepoint()
to avoid failure with SQLServer.
@aboisvert I guess you wanted to reply here, so I will reply here.
I can try to implement that conditional call to releaseSavepoint()
, but I suspect at the time I faced this it was not trivial. But meanwhile I gained a bit more knowledge about scalasql. I will try again.
However what worries me is that no test failed when I commented this line. I also need to investigate that...
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.
I don't know why no tests failed when commented out, I thought we did have pretty good tests for a variety of transaction/savepoint scenarios in https://github.com/com-lihaoyi/scalasql/blob/main/scalasql/test/src/api/TransactionTests.scala, but maybe I missed a spot
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.
I can try to implement that conditional call to
releaseSavepoint()
, but I suspect at the time I faced this it was not trivial.
I revisited this today, and indeed I can't just write dialect.isInstanceOf[MsSqlDialect]
because in core
I don't have access to MsSqlDialect
.
Shall I add an def supportSavepointRelease: Boolean
to DialectConfig
? Shall I add a try/catch and swallow the exception?
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.
let's go with def supportSavepointRelease: Boolean
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.
done in 63c538a
Those are related to this comment. I think the code generated by the scala3 macro is calling this code, but not the scala2 generated code. Do you have any hint? The scala 2.x tests are green... |
I don't have any hints haha, Scala 3 support was contributed by @mrdziuban a while back. Maybe he has some ideas, but if not we'll have to investigate this and ourselves and figure out what's going on |
Here are my (unsolicited) thoughts,
|
No worries. I left this for the end because troubleshooting macros is always a pain... |
I've started looking into this and can reproduce it by loading a console in the test project: ./mill -i scalasql[3.4.2].test.console then running this: import scalasql._
import scalasql.dialects.MsSqlDialect._
case class Foo[T[_]](b: T[Boolean])
object Foo extends Table[Foo]
scalasql.example.MsSqlExample.mssqlClient.renderSql(Foo.select)
// SELECT CASE WHEN foo0.b THEN 1 ELSE 0 END AS b FROM foo foo0 What I've learned is that the That class is constructed by And I don't yet understand why Instead Scala 2 is resolving this other So @jtjeferreira, should |
thx @mrdziuban, your comment was very useful. I am still experimenting a few alternatives... |
Continues the work of #29
Current status: 2 tests failing