Skip to content

Conversation

@natri0
Copy link

@natri0 natri0 commented May 1, 2025

Description

Summary of the change: Adds a way to filter referrersOn/optionalReferrersOn

Detailed description:

  • What: Two new methods for the DAO API: View.referrersOn and View.optionalReferrersOn.
  • Why: This seems like a niche yet requested feature that has been stale for 9 months according to the YouTrack issue.
  • How:
    • moved the condition generating logic in Referrers to a separate method subclasses can override
    • added a new ViewReferrers class representing a referrersOn with a View left-hand side parameter (as opposed to EntityClass)

Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

EXPOSED-462

natri0 added 5 commits April 28, 2025 00:17
Now it's possible to additionally filter the child entities on a one-to-many relationship by using a `View` as the left-hand-side parameter for `referrersOn`:

    val kids by User.view { Users.age less 18 } referrersOn Users.city

This example was added to SamplesDao to show off the new feature.

FIXME: tried adding eager loading but it seems like there's no way to filter entities based on the Op, so might for now be impossible.

TODO: write tests
I don't know how to actually make the caching work there. :(
Seems like we'd have to evaluate the custom WHERE clause from the View and filter based on that, but it doens't look like there's any way to evaluate a Op<Boolean>.
@natri0
Copy link
Author

natri0 commented May 1, 2025

though I didn't figure out how caching is supposed to work in this case, so if anyone has any thoughts would be thankful.

@yanghuilong
Copy link

I would like to know what the current status of this feature is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants