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
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 ....
In my test code, inserts appear to be happening twice. noticed it when the unique index was violated.
However, this doesn't seem to be happening when I run your test case. So just wondering if you've seen something similar before?
Peter Hancox
@phancox
This was my problem:
val profile = if (dbmsName == "PostgreSQL") PostgresDriver else dc.driver
I override the driver for PostgreSQL to drop the identifier quotes. This is why making the change to forConfig[....] threw errors in my code here. I'll still have to take care of this issue but should be much simpler.
nafg
@nafg
so instead of PostgresDriver use MyPostgresDriver where
object MyPostgresDriver extends PostgresDriver with KeyedTableComponent
then the LUB will include KeyedTableComponent
Peter Hancox
@phancox
yep, pretty straight forward. Presume the double insert doesn't ring any bells?
nafg
@nafg
WDYM?
What double insert?
Peter Hancox
@phancox
My test suite threw a uniqueness violation when I inserted a single record. Removed the constraint and it is in fact adding two records for a single insert. Running your test suite doesn't seem to have any problem. So just wondering if you had any ideas?
nafg
@nafg
No, can you provide code that demonstrates the issue?