--
---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
This is definitely a Slick bug that shows up with Postgres but not MySql. I did not see any Slick unit tests that covered using autoInc with the * projection. The workaround is to modify the definition of autoInc so that it does not reference the * projection, like this:
See you at Scala Days 2013 in NYC!
June 10th - June 12th
www.scaladays.org
Stefan,
Code that runs on Slick + MySQL does not compile against Slick + Postgres. I would call that a bug.
There should be a comprehensive suite of tests against all supported databases, not just an in-memory database. This would ensure that Slick behaves consistently regardless of the database that it is connected to. If this was done, the bug would have been caught.
Stefan,
1) "Discouraged"? No warnings are mentioned in the documentation.
2) I did not show any code that inserted into an autoinc column.
3) No other persistence mechanism that I am aware of restricts a value from being supplied for autoinc. Why should Slick be different?
4) I do not see tests for MySQL, Postgres or other supported databases in the Slick project. Where are these tests that you refer to?
5) Your responses have wandered from the original topic I posted. If you refer back to my original posting, I reported a compilation error on valid Slick code that worked for MySQL and not for Postres.
If Slick is not expected to behave consistently for all databases, then the documentation needs to say this in big red bold type, and there would be
If Slick is not expected to behave consistently for all databases, then the documentation needs to say this in big red bold type
def * = (userId, name, refName, id.?) <> (Role, Role.unapply) // I think
So the "autoinc" workaround doesn't seem to work.
Do you have any suggestions?
Thanks.
def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
Postgres automatically makes my column non-null:
Column | Type | Modifiers
---------+--------------------------------+-----------
id | integer | not null
And when I try to insert a new column via Slick,
I get this following error:org.postgresql.util.PSQLException: ERROR: null value in column "id" violates not-null constraint.
All this is perhaps because I don't fully understand and therefore fix the default projection in my table definition, not sure...
I'd greatly appreciate if you have any further insight.
Column | Type | Modifiers
---------+--------------------------------+-----------
id | integer | not null
After:
Column | Type | Modifiers
--------+-----------------------+----------------------------------------------------
id | integer | not null default nextval('tests_id_seq'::regclass)
Thanks Daghan Altas, makes me have the first woking sample (https://github.com/renexdev/play-slick-computer-database-mod) with play 2.4, play-slick 1.0.0. Cheers