-
Notifications
You must be signed in to change notification settings - Fork 666
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
feat: EXPOSED-368 Ordering on References #2083
Conversation
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.
via()
(the InnerTableLink
reference) also returns a SizedIterable
that should be possible to order in the same way. Could this be added at the same time?
|
||
abstract class BaseReferrers<ParentID : Comparable<ParentID>, in Parent : Entity<ParentID>, ChildID : Comparable<ChildID>, out Child : Entity<ChildID>, REF>( |
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.
Will this switch cause any issue for the other reference classes that delegate to OptionalReferrers
?
Also, is the plan to deprecate OptionalReferrers
and then drop this new class after in favor of Referrers
alone? If so, would it be better to just have duplicate code in the 2 existing classes, that way we'd only have to deprecate one class. Without having to introduce a new temporary class into the API.
Unless the plan is to push that second PR before this one is released, so BaseReferrers
doesn't actually enter the API.
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.
It was actually open question what is better to do, and the variant to mark OptionalReferrers
as deprecated looks good to me.
In order to avoid one more class in API it's not a problem to inherit OptionalReferrers
from Referrers
(but the last one should be open
). Pushed such a variant, but we can discuss it again.
...ests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/entities/OrderedReferenceTest.kt
Outdated
Show resolved
Hide resolved
...ests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/entities/OrderedReferenceTest.kt
Outdated
Show resolved
Hide resolved
...ests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/entities/OrderedReferenceTest.kt
Outdated
Show resolved
Hide resolved
…t for changed orderBy, add orderBy to InnerTableLink (`via()`)
Added ordering to |
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.
Looks good, just a typo in one of the KDocs.
PR add the possibility to add sorting for one-to-many references. Usage looks like:
Open questions that I haven't yet resolved:
The reason is the caching of referencing rules inside
EntityClass::refDefinitions
. Every time we try to add a reference to the same column, the cached one is returned.Solution options:
Referrers
andOptionalReferrers
, but to me one of them (for instanceOptionalReference
) looks redundant. They do the same thing and have only a small difference in fieldreference
(in one case it has typeColumn<REF>
in anotherColumn<REF?>
, but since REF is generic, it can be specified one level above. It will look like:After that
OptionalReferrers
can be removed. The only reason to keep it I see is the semantic (previous variant is better readable from user perspective).For now I created
BaseReferrers
to place common logic inside one class, but I can join all of these 3 classes (Referrers
,OptionalReferrers
,BaseReferrers
) into oneReferrers
.