-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: sqlserver / mssql support #505
Conversation
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.
looking good
|
||
override def encode(timestamp: Instant): LocalDateTime = LocalDateTime.ofInstant(timestamp, zone) | ||
|
||
override def now[T](): T = LocalDateTime.ofInstant(instantNow(), zone).asInstanceOf[T] |
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.
that cast to T
looks dangerous, for example this usage:
override def currentDbTimestamp(): Future[Instant] = Future.successful(timestampCodec.now())
wouldn't that cast a LocalDateTime to an Instant?
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.
Yes, right. I am fixing this now. It seems I can get rid of def now[T](): T
completely, and fix the places where I am not yet binding a timestamp with the codec specific .bindTimestamp
.
The unsafe casts must not yet have been triggered I assume.
core/src/main/scala/akka/persistence/r2dbc/internal/codec/TimestampCodec.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/postgres/PostgresQueryDao.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/postgres/PostgresQueryDao.scala
Outdated
Show resolved
Hide resolved
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.
looking good, a few comments about the timestamps
core/src/main/scala/akka/persistence/r2dbc/internal/codec/TimestampCodec.scala
Outdated
Show resolved
Hide resolved
|
||
override def decode(row: Row, name: String): Instant = toInstant(row.get(name, classOf[LocalDateTime])) | ||
|
||
override def encode(timestamp: Instant): LocalDateTime = LocalDateTime.ofInstant(timestamp, zone) |
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.
this is good, it wouldn't surprise me if r2dbc-sqlserver would add support for binding Instant in a future version. seems like a missing thing to me. anyway, for us this is good now
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.
core/src/main/scala/akka/persistence/r2dbc/internal/codec/TimestampCodec.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/sqlserver/SqlServerQueryDao.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/sqlserver/SqlServerQueryDao.scala
Outdated
Show resolved
Hide resolved
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.
Looking good, left some questions and nitpicks but I think the only big thing missing is documentation.
core/src/main/scala/akka/persistence/r2dbc/internal/codec/TagsCodec.scala
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/codec/TimestampCodec.scala
Outdated
Show resolved
Hide resolved
@@ -74,6 +74,7 @@ class MigrationToolSpec | |||
|
|||
private val migration = new MigrationTool(system) | |||
|
|||
// enable for sqlserver as well? |
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.
Seems fine if it passes, if not, not sure it is important to deal with right away.
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.
Table creation would need to be tailored for sqlserver, skipping it for now.
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.
Should I create a ticket for 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.
The migration tool is only using methods in the dao that we are using for other things already, if I'm not misremembering. Therefore it is not that important to test it with all dialects. I think the comment can be removed and nothing more.
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.
@sebastian-alfers I think I misunderstood. The question wasn't only about the test. The MigrationTool has it's own MigrationDao, which would be different for sqlserver. Please create an issue and we handle it if it comes up as a request.
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.
core/src/main/scala/akka/persistence/r2dbc/internal/sqlserver/SqlServerDurableStateDao.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/sqlserver/SqlServerJournalDao.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/sqlserver/SqlServerQueryDao.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/sqlserver/SqlServerSnapshotDao.scala
Outdated
Show resolved
Hide resolved
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.
LGTM with a few more nitpicks and CI green. Would be good with a second LGTM before merging though.
core/src/main/scala/akka/persistence/r2dbc/internal/postgres/PostgresDurableStateDao.scala
Outdated
Show resolved
Hide resolved
core/src/main/scala/akka/persistence/r2dbc/internal/postgres/PostgresQueryDao.scala
Outdated
Show resolved
Hide resolved
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.
Looking good, only a few minor things.
Maybe it can be worth looking at the dialect in Akka Projections before we release to see that this fits in with that.
|
||
package akka.persistence.r2dbc.internal.codec | ||
|
||
trait QueryAdapter { |
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.
private[akka]
on all these internal classes, and the usual InternalApi markers
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.
Maybe some of these will be needed for the sqlserver dialect in Akka Projections?
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 look into projections regarding sqlserver.
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 was building the sqlserver
dialect in projections based on a publishLocal
snapshot from this branch, and did not see any problems in this regards.
I looked at projections and did not see anything missing, when it comes to integrating changes from this PR. |
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.
LGTM
…SqlServerDurableStateDao.scala Co-authored-by: Johan Andrén <[email protected]>
…SqlServerJournalDao.scala Co-authored-by: Johan Andrén <[email protected]>
…SqlServerSnapshotDao.scala Co-authored-by: Johan Andrén <[email protected]>
…SqlServerQueryDao.scala Co-authored-by: Johan Andrén <[email protected]>
6410fc8
to
86e8251
Compare
Next iteration based on discussion in #494.
Note that in the sqlserver specific overrides, named binding is still used. This is recommended by the plugin, and my have several advantages:
getAndIncIndex
approach for conditional binding,However, I see this is not aligned with the rest of the project, so I have no problem with converting to positional binding for where it is not yet used.
More notes:
DEBUG