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

Slick: factory method SlickSession.forDbAndProfile #1996

Merged
merged 3 commits into from
Nov 7, 2019

Conversation

Kreinoee
Copy link
Contributor

@Kreinoee Kreinoee commented Oct 31, 2019

Purpose

Introduces an extra factory method for creating a SlickSession out of Slick Database and Profile instances.

References

References #1509

Changes

  • Created method forDbAndProfile(db: JdbcBackend#Database, profile: JdbcProfile): SlickSession in the scaladsl version.
  • Before this changes, the scala version of SlickSession object was the same as the javadsl version. Now these two are different, as the above method, only makes sense from scala, due to Slicks missing Java API.
  • To avoid duplicat code, all the shared logic of the two SlickSession objects, has been moved to a SlickSessionFactory abstract class, that they both extend.

Background Context

It makes it possible to create a SlickSession, if you starting point is a Slick Database instance. This can be the case, when working with other libraries, that are based on Slick, but now nothing about Alpakka. In my case, it was a test library, that provides each test, with its own test database, provided as a Slick Database instance.

* Added the method SlickSession.forDbAndProfile(db: JdbcBackend#Database, profile: JdbcProfile)
* Moved the method SlickSession.forDbAndProfile(db: JdbcBackend#Database, profile: JdbcProfile) to the scaladsl version of SlickSession, as slick offers no good Java API for creating a Database instance.
* Created abstract class SlickSessionFactory, and letting both the javadsl and scaladsl version of SlickSession object extends it, to avoid duplicating the shared factory methods.
* Made the unit test for the factory method close the connection it creates, and the end of the test.
* Added documentation about the new way of creating a SlickSession instance.
Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

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

LGTM.

@ennru
Copy link
Member

ennru commented Nov 6, 2019

You need to add MiMa exclusions in a file slick/src/main/mima-filters/1.1.x.backwards.excludes
See https://travis-ci.com/akka/alpakka/jobs/251451264#L679

    * Added line for ignoring akka.stream.alpakka.slick.javadsl.SlickSession$SlickSessionImpl.
    * Added line for ignoring akka.stream.alpakka.slick.scaladsl.package.SlickSession.
@Kreinoee
Copy link
Contributor Author

Kreinoee commented Nov 7, 2019

Done, thanks for the hint.

@ennru ennru changed the title Slick: Extra factory method: SlickSession.forDbAndProfile(db: JdbcBackend#Database, profile: JdbcProfile) (#1509) Slick: factory method SlickSession.forDbAndProfile Nov 7, 2019
@ennru ennru merged commit 2b86805 into akka:master Nov 7, 2019
@ennru ennru added this to the 2.0.0 milestone Nov 7, 2019
@ennru
Copy link
Member

ennru commented Nov 7, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants