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

[play-]slick now comes with Scala 3 artifacts #368

Merged
merged 9 commits into from
Feb 25, 2024

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Jul 15, 2023

No description provided.

@mkurz
Copy link
Member Author

mkurz commented Jul 15, 2023

Hey @nafg,

I am running into problems upgrading to latest slick 3.5.0-M4 with Scala 3 support. Do you mind taking a look yourself if you have time?
To reproduce:

git clone [email protected]:mkurz/play-samples.git
cd play-samples
git checkout slick_scala3

cd play-scala-isolated-slick-example
# Set the scala version for the test script:
export MATRIX_SCALA=3.x
# Run the test script:
./scripts/test-sbt

You will see errors:

[error] -- Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:4:22 
[error] 4 |object Tables extends {
[error]   |                      ^
[error]   |                      `extends` must be followed by at least one parent
[error] -- [E009] Syntax Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:6:2 
[error] 6 |} with Tables
[error]   |  ^^^^
[error]   |  Early definitions are not supported; use trait parameters instead
[error]   |
[error]   | longer explanation available when compiling with `-explain`
[error] -- Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:6:7 
[error] 6 |} with Tables
[error]   |       ^^^^^^
[error]   |       end of toplevel definition expected but identifier found
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:36:27 
[error] 36 |    FlywaySchemaHistoryRow.tupled((<<[Int], <<?[String], <<[String], <<[String], <<[String], <<?[Int], <<[String], <<[java.time.Instant], <<[Int], <<[Boolean]))
[error]    |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value tupled is not a member of object Tables.this.FlywaySchemaHistoryRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:41:153 
[error] 41 |    def * = (installedRank, version, description, `type`, script, checksum, installedBy, installedOn, executionTime, success) <> (FlywaySchemaHistoryRow.tupled, FlywaySchemaHistoryRow.unapply)
[error]    |                                                                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value tupled is not a member of object Tables.this.FlywaySchemaHistoryRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:43:268 
[error] 43 |    def ? = ((Rep.Some(installedRank), version, Rep.Some(description), Rep.Some(`type`), Rep.Some(script), checksum, Rep.Some(installedBy), Rep.Some(installedOn), Rep.Some(executionTime), Rep.Some(success))).shaped.<>({r=>import r._; _1.map(_=> FlywaySchemaHistoryRow.tupled((_1.get, _2, _3.get, _4.get, _5.get, _6, _7.get, _8.get, _9.get, _10.get)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))
[error]    |                                                                                                                                                                                                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value tupled is not a member of object Tables.this.FlywaySchemaHistoryRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:82:13 
[error] 82 |    UsersRow.tupled((<<[String], <<[String], <<[java.time.Instant], <<?[java.time.Instant]))
[error]    |    ^^^^^^^^^^^^^^^
[error]    |    value tupled is not a member of object Tables.this.UsersRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:86:59 
[error] 86 |    def * = (id, email, createdAt, updatedAt) <> (UsersRow.tupled, UsersRow.unapply)
[error]    |                                                  ^^^^^^^^^^^^^^^
[error]    |             value tupled is not a member of object Tables.this.UsersRow
[error] -- [E008] Not Found Error: ./play-samples/play-scala-isolated-slick-example/modules/slick/target/scala-3.3.0/src_managed/main/com/example/user/slick/Tables.scala:88:124 
[error] 88 |    def ? = ((Rep.Some(id), Rep.Some(email), Rep.Some(createdAt), updatedAt)).shaped.<>({r=>import r._; _1.map(_=> UsersRow.tupled((_1.get, _2.get, _3.get, _4)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))
[error]    |                                                                                                                   ^^^^^^^^^^^^^^^
[error]    |             value tupled is not a member of object Tables.this.UsersRow
[warn] two warnings found
[error] 9 errors found

Also the play-scala-slick-example example is failing if you run it with Scala 3 with the ./scripts/test-sbt script.

@nafg
Copy link

nafg commented Jul 17, 2023

Your issue is that while the application is built against 3.5.0-M4, that's not the code generator you're using. Instead, your sbt built uses https://github.com/tototoshi/sbt-slick-codegen which is built for Slick 3.3.3.

I tried overriding the transitive dependency in the SBT build and got a NoSuchMethodError. So that plugin needs to be built against an updated Slick version.

@mkurz mkurz merged commit 4cf5af3 into playframework:2.9.x Feb 25, 2024
17 checks passed
@mkurz mkurz deleted the slick_scala3 branch February 25, 2024 09:35
@mkurz
Copy link
Member Author

mkurz commented Feb 25, 2024

Finally, this works. Scala 3 required the usual adjustments, however 5318222 required a bit more attention. Companies nested inside the CompaniesComponent trait didn't work well, so I just removed it since I couldn't see a real benefit. Very likely the problem is caused because of https://docs.scala-lang.org/scala3/reference/dropped-features/type-projection.html which we hit in play-silhouette already (starting conversation here: playframework/play-silhouette#36 (comment))

@mkurz
Copy link
Member Author

mkurz commented Feb 25, 2024

@Mergifyio backport 3.0.x

Copy link
Contributor

mergify bot commented Feb 25, 2024

backport 3.0.x

✅ Backports have been created

mkurz added a commit that referenced this pull request Feb 25, 2024
[3.0.x] [play-]slick now comes with Scala 3 artifacts (backport #368) by @mkurz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants