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

chore: Make Sql.Interpolation backwards compatible #514

Merged
merged 5 commits into from
Feb 2, 2024

Conversation

patriknw
Copy link
Member

@patriknw patriknw commented Feb 2, 2024

Follow up to #505
Sql.Interpolation is used in other projects that we don't want to break.

Also a cleanup of the codec settings.

@@ -1,8 +1,4 @@
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.r2dbc.R2dbcSettings.this")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file should be latest release, 1.2.1, not 1.2.2

* interpolation arguments `$` can be used.
*/
@InternalApi private[akka] implicit class InterpolationWithAdapter(val sc: StringContext)(implicit
adapter: QueryAdapter)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryAdapter is private[akka] and therefore I think the InterpolationWithAdapter should also be private[akka], otherwise we should also make QueryAdapter public (InternalStableApi)

Note that this is AnyRef because of two parameters, instead of AnyVal. I'm not sure this idea with the adapter is worth the indirect complexity it adds. Doesn't we override all sql for sqlserver anyway in the SqlServerDao classes? Those could use @ as the placeholder instead of ? and then we could change the ordinary fillInParameterNumbers to look for ? and @ and replace accordingly. I'll might try that in a separate pr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we don't override all sql, which is good. I'll think a little more about this, but this PR can be merged seperately

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we do not override all sql statements, which is why this QueryAdaper was introduced.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave it as this for now. Projections will still be able to use QueryAdapter since it's private[akka].

@patriknw patriknw force-pushed the wip-compatibility-patriknw branch from 226a9b5 to 6d30fdf Compare February 2, 2024 11:44
val queryAdapter: QueryAdapter) {

// implicits that can be imported
object JournalImplicits {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not seen this very often, objects within a case class. But I guess it is fine. Alternative could be something based on inheritance or so, this this CodecSettings.this.journalPayloadCodec could be avoided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodecSettings.this.journalPayloadCodec was just because I used the same names

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the object is only for name scoping

@@ -44,6 +44,7 @@ private[r2dbc] class SqlServerDurableStateDao(
connectionFactory: ConnectionFactory,
dialect: Dialect)(implicit ec: ExecutionContext, system: ActorSystem[_])
extends PostgresDurableStateDao(settings, connectionFactory, dialect) {
import settings.codecSettings.DurableStateImplicits._
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, this means imports within the parent class are not available in the sub-class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a side effect, but I think it's good to be more explicit about the implicits. Can be difficult to understand where they come from otherwise.

Copy link
Contributor

@sebastian-alfers sebastian-alfers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement to avoid having to import each coded individually.

@patriknw patriknw merged commit a7ac7e0 into main Feb 2, 2024
8 checks passed
@patriknw patriknw deleted the wip-compatibility-patriknw branch February 2, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants