-
Notifications
You must be signed in to change notification settings - Fork 180
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
Scala 3 support #677
Scala 3 support #677
Conversation
Is my understanding correct that scala 2 functionality remains the same and this successfully adds scala 3 support for almost everything? |
Pretty much, the differences are clearer if you compare to #676 (which I opened to separate the bulk of the noise from the 'real' changes) but there are some differences:
It would be possible to denormalise the code further, as it were, and retain completely identical scala 2 support,. however I felt like that'd be making a rod for our own back and it was probably better to do a more sweeping change |
Probably also worth noting that some cool fun syntax doesn't work in scala 3, so there are definitely regressions on that front too, but for the most part they're regexable. Edit: this only applies to scala 3 but it could make upgrading some stuff more painful |
@tminglei can you please review, merge and get this released? |
What I should do is remove the Struct entirely from scala 3 to push the breaking change up to the type level |
There we go, removed a mine hopefully Edit: actually I'm now certain that the Struct functionality can indeed be implemented with inline and hope to push that up in the next couple of hours |
implicit val RangeToString: RegisteredTypeConverter[Range[LocalDateTime], String] = | ||
RegisteredTypeConverter(PgRangeSupportUtils.toStringFn[LocalDateTime](_.toString)) | ||
implicit val MapToString: RegisteredTypeConverter[Map[String, String], String] = RegisteredTypeConverter(mapToString) | ||
implicit val StringToMap: RegisteredTypeConverter[String, Map[String, String]] = RegisteredTypeConverter(stringToMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is different to scala 2 usage -- rather than 'register'ing a typetag, we need to have an appropriate implicit 'registered converter' in scope. This all boils down to the composite type being constructed at compile time rather than runtime, and I think it's actually an improvement. Sadly it does mean some inconsistency between scala 2 and scala 3 APIs, because we can't use typetags in scala 3 and can't use inline in scala 2, but hey ho them's the breaks
@tminglei are you able to take a look at this please? Happy to make changes, but would love to start the process of migrating to scala 3 and this is the last significant dependency I have that's not yet crosspublished |
@@ -53,12 +53,12 @@ trait PgPostGISExtensions extends JdbcTypesComponent { driver: PostgresProfile = | |||
case Some(p) => om.column(GeomLibrary.LineFromEncodedPolyline, encodedPolyline.toNode, LiteralNode(p)) | |||
case None => om.column(GeomLibrary.LineFromEncodedPolyline, encodedPolyline.toNode) | |||
} | |||
def makeBox[G1 <: GEOMETRY, P1, G2 <: GEOMETRY, P2, R](lowLeftPoint: Rep[P1], upRightPoint: Rep[P2])( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know why we needed a second geometry subtype here... Anyway scala 3 seemed to struggle with the type inference, and rather than specifying everything I decided to simplify the signature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hughsimpson can't remember it exactly.
I think your changes should be ok after double checked the official docs.
@hughsimpson merged. Thanks very much! 👍 |
@tminglei thanks! BTW I see you published to maven central, but I didn't realize it at first because there isn't an M5 tag or release on GitHub. |
Published. |
Builds on #676 and #668 to fix compilation for scala 3.
Couple of issues (although I'm not sure if I personally consider them blockers..):
makeBox
/makeBox3d
/makeLine
slightly less general, although I've never used this and don't know if it's a real issuebumps play-json major versionreverted. Not sure why I thought I needed to do thatdoes not implement Composite support for scala 3 (I had a crack at implementing that with scala 3 inline, but ran into a wall. Probably needs full-fat macros. Personally I don't use this functionality of slick-pg at all, so I believe it's still worth merging without)Now implements composite (Struct) support for scala 3. It's a different mechanism -- requires some implicits, uses scala 3 inline -- but passes the test suite