-
Notifications
You must be signed in to change notification settings - Fork 642
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/JDBC create SlickSession from Database and Profile. #1509
Comments
Yes, this sounds useful (even the |
* Added the method SlickSession.forDbAndProfile(db: JdbcBackend#Database, profile: JdbcProfile)
Sorry for the delay, but gut stuck on other projects. I may need some help here. I have made a fix, that works for me now. However for being able to build alpakka at all, I had to remove a lot of stuff from the build files. As you contributions policies require, I would like add some documentation for this new way of creating a SlickSession. However when i try to run docs/previewSite sbt task, I get a lot of errors like:
This could very well be caused by all the stuff that I have deleted in the build file, but if I revert the changes in the build files, or just try on a fresh clone of alpakka, I cannot even start sbt, due to this error:
Is there some global repo there should be set in sbt or something? |
There is a problem with downloading the Mima plugin. Try this workaround lightbend-labs/mima#422 (comment) |
You know what? It is fixed now. No need to work around it anymore. |
* 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.
* Added line for ignoring akka.stream.alpakka.slick.javadsl.SlickSession$SlickSessionImpl. * Added line for ignoring akka.stream.alpakka.slick.scaladsl.package.SlickSession.
This was implemented with #1996. |
Short description
It should be possible to create a SlickSession, from a Database object and a Profile object.
Details
A SlickSession is basically just a wrapper arround a Database and a Profile, but you ironically, you cannot create it, if these two objects are your starting point. Currently its only possiby to create a SlickSession from a Config or a DatabaseConfig.
I have a situation, where I use another Library, that supplies a Database object to me, for using in unit tests. So my problem is, that I have the Database object, and now what Profile to use with it, and therefore have the two things that makes up a SlickSession, but I have no easy way of actually creating the needed SlickSession instance.
I would suggest creating an extra forDatabaseAndProfile factory method, to SlickSessions companion object. I have created a Local fork to test it out, and it works fine, so I can provide it as a pull request on the other side of the weekend.
The text was updated successfully, but these errors were encountered: