Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 28 17:19
  • Jun 23 20:28
    anqit starred nafg/slick-additions
  • May 24 19:55

    mergify[bot] on master

    Update scalameta to 4.5.8 Merge pull request #197 from sc… (compare)

  • May 24 19:55
    mergify[bot] closed #197
  • May 24 19:53
    scala-steward opened #197
  • May 18 19:44

    mergify[bot] on master

    Update scalameta to 4.5.7 Merge pull request #196 from sc… (compare)

  • May 18 19:44
    mergify[bot] closed #196
  • May 18 19:42
    scala-steward opened #196
  • May 05 16:34

    mergify[bot] on master

    Update scalameta to 4.5.6 Merge pull request #195 from sc… (compare)

  • May 05 16:34
    mergify[bot] closed #195
  • May 05 16:32
    scala-steward opened #195
  • Apr 30 16:46

    mergify[bot] on master

    Update scalameta to 4.5.5 Merge pull request #194 from sc… (compare)

  • Apr 30 16:46
    mergify[bot] closed #194
  • Apr 30 16:44
    scala-steward opened #194
  • Apr 25 04:36

    mergify[bot] on master

    Update scalatest to 3.2.12 Merge pull request #193 from sc… (compare)

  • Apr 25 04:36
    mergify[bot] closed #193
  • Apr 25 04:33
    scala-steward opened #193
  • Apr 15 20:35

    mergify[bot] on master

    Update scalameta to 4.5.4 Merge pull request #192 from sc… (compare)

  • Apr 15 20:35
    mergify[bot] closed #192
nafg
@nafg
@phancox oh I see, that's a different problem than the one I though you were hitting, which has nothing to do with cake. I don't usually use forConfig, let me see how it works...
@phancox where is the code based off of?
Peter Hancox
@phancox
just looks up a config file to determine which driver to use
come from the activator template for Slick 3.0
nafg
@nafg
Ok
So let's look at the scaladocs. If you look at
You see that forConfig[P] returns a DatabaseConfig[P],
you can see that DatabaseConfig[P]#driver: P
that is, the val driver of a DatabaseConfig[P] has type P
Which is the type parameter to forConfig
Peter Hancox
@phancox
So can I do DatabaseConfig.forConfig[JdbcProfile with KeyedTableComponent](config) or something to that effect?
nafg
@nafg
Sounds good to me
And indeed it seems it does choose the driver at run time
if you use that API
Personally I usually do it like this:
Peter Hancox
@phancox
Thought that was going to work but doesn't seem to
nafg
@nafg
trait Abstract {
  val driver: JdbcProfile with KeyedTableComponent
  val db: driver.Database
}
object Concrete extends Abstract {
  object driver extends PostgresDriver with KeyedTableComponent
  import driver.api._
  val db = Database.forConfig ...
}
What issue are you getting?
Peter Hancox
@phancox
The forConfig statement seems fine with that change. But EntityTable etc are no longer defined in the trait that references the driver
nafg
@nafg
Can you show in a scastie?
Also it's in driver.api._
Peter Hancox
@phancox
What I can't do with the code you just showed me is select a different database such as H2 in the config file
nafg
@nafg
yeah my code made that mistake, let me edit
k
@phancox right, I usually do it at compile time, not runtime. That's the distinction
Peter Hancox
@phancox
I won't waste any more of your time then. Just wanted to make sure that I hadn't missed the obvious.
If you haven't used this code with dynamic database selection before, then I'll try and make it work myself.
nafg
@nafg
@phancox if you show me a scastie with DatabaseConfig.forConfig not working, maybe I can help
Peter Hancox
@phancox
Not that proficient with the scastie given I'm scattered across multiple modules. Thhis one shoes the module where I do the database setup http://scastie.org/11255
I'll amend it for the change we just discussed and try and add the entity class in
nafg
@nafg
First of all, change the dependency to slick-additions
0.4.0-RC2 should work
Peter Hancox
@phancox
http://scastie.org/11261 sorry didn't know the package name
Peter Hancox
@phancox
Any ideas?
nafg
@nafg
http://scastie.org/11262 fixes the organization name
Oh I have to add the resolver
it's on bintray (jcenter)
Peter Hancox
@phancox
Guess it needs imports? In my code I've just copied your two scala files into my package
nafg
@nafg
Need an import
Compiles fine
ouch ;)
For the same price you could have looked up the organization setting in build.sbt...
Peter Hancox
@phancox
Looks good, thanks.
My problem wasn't the imports but I think I might have screwed up the val profile
My actual code is a bit more complicated, you have the simplified version.
One more thing ....