♻️ refactor: remove Compat methods in favour on their implementation#721
Merged
Conversation
…directly This code was different when we were cross building to Scala 2.11/2.12 but not required anymore
gaeljw
commented
Jun 14, 2026
There was a problem hiding this comment.
Pull request overview
This PR removes the internal anorm.Compat helper layer and rewrites call sites to use standard library APIs directly (e.g., right-biased Either, lazyZip, collection conversions), reflecting the project’s current Scala 2.13/3 baseline.
Changes:
- Replaced
Compatcollection/type aliases (Trav,LazyLst) withIterable/LazyListand inlined helper methods (rightMap,rightFlatMap,toMap, etc.). - Updated parsing/mapping code paths to use direct
Eitherand collection operations. - Removed
core/src/main/scala/anorm/Compat.scalaand added MiMa filters for the missingCompatclasses.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/scala/anorm/ToStatementMisc.scala | Switch stream/traversable handling from Compat.* aliases to LazyList/Iterable. |
| core/src/main/scala/anorm/ToSql.scala | Same refactor for SQL fragment generation over streams/iterables. |
| core/src/main/scala/anorm/TopLevelDefinitions.scala | Replace Compat Java-enum iterator helper with scala.jdk.CollectionConverters usage. |
| core/src/main/scala/anorm/SqlParser.scala | Inline Either right-bias operations (remove Compat.rightFlatMap). |
| core/src/main/scala/anorm/Row.scala | Replace Compat.lazyZip/toMap helpers with direct lazyZip and .to(Map). |
| core/src/main/scala/anorm/MetaData.scala | Replace Compat.toMap/toFlatMap with view + .to(Map) equivalents. |
| core/src/main/scala/anorm/Cursor.scala | Replace Compat.lazyZip usage with direct lazyZip. |
| core/src/main/scala/anorm/Compat.scala | Removed the Compat object entirely. |
| core/src/main/scala/anorm/Column.scala | Inline Either.map/flatMap where Compat.rightMap/rightFlatMap was used. |
| core/src/main/scala/anorm/BatchSql.scala | Replace Compat.Trav with Iterable in public/internal APIs. |
| core/src/main/scala-3/anorm/macros/ToParameterListImpl.scala | Remove unused Compat import after refactor. |
| core/src/main/scala-3/anorm/macros/Inspect.scala | Remove unused Compat import after refactor. |
| core/src/main/scala-2/anorm/macros/ToParameterListImpl.scala | Replace Compat helpers with view.mapValues, view.collect, .to(Map). |
| core/src/main/scala-2/anorm/macros/Inspect.scala | Replace Compat.Trav with Iterable and direct lazyZip. |
| build.sbt | Add MiMa excludes for removed anorm.Compat classes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use direct two-argument lambdas for lazyZip mappings so the code matches the LazyZip API more clearly. Avoid allocating temporary single-entry maps when building aliased metadata dictionaries.
mkurz
approved these changes
Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Purpose
Clean code.
Background Context
This code was different when we were cross building to Scala 2.11/2.12 but not required anymore.