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

Queries no longer retrieving deep soft-deleted paths when fetchLazy are chained #2852

Open
patrickspensieri opened this issue Sep 29, 2022 · 0 comments

Comments

@patrickspensieri
Copy link

patrickspensieri commented Sep 29, 2022

Expected behavior

See conversation in Ebean Group.

As of version 13.6.6, queries no longer retrieve deep soft-deleted paths when multiple fetchLazy(path) are chained. This differs from

  • Versions prior to 13.6.6
  • and from fetch(), which doesn't have issues with multiple fetch paths like query .setIncludeSoftDeletes().fetch("account").fetch("account.environment")

The minimal reproduction PR linked below demonstrates workarounds.

Actual behavior

// demonstrates new behaviour in 13.6.6
// when: lazy fetching serviceAccount AND serviceAccount.environment
List<UsageRaw> lazyUsageMultiplePaths = server.find(UsageRaw.class)
  .setIncludeSoftDeletes()
  .fetchLazy("serviceAccount")
  .fetchLazy("serviceAccount.environment")
  .findList();
// then: soft-deleted environments are NOT loaded (not the case before 13.6.6)
assert(lazyUsageMultiplePaths.size() == 2);
assert(lazyUsageMultiplePaths.stream().allMatch(accountLoaded()));
assert(lazyUsageMultiplePaths.stream().filter(environmentLoaded()).count() == 1);

// demonstrates workaround, use single path, all required properties are loaded
// when: lazy fetching serviceAccount.environment
List<UsageRaw> lazyUsageSinglePath = server.find(UsageRaw.class)
  .setIncludeSoftDeletes()
  .fetchLazy("serviceAccount.environment")
  .findList();
// then: soft-deleted environments loaded
assert(lazyUsageSinglePath.size() == 2);
assert(lazyUsageSinglePath.stream().allMatch(accountLoaded()));
assert(lazyUsageSinglePath.stream().allMatch(environmentLoaded()));
// models
public class Usage {
  UUID id
  String name
  @ManyToOne
  Account account
}

public class Account {
  UUID id
  String name
  @OneToOne
  Environment environment
  @SoftDelete
  boolean deleted
}

public class Environment {
  UUID id
  String name
  @SoftDelete
  boolean deleted
}

Steps to reproduce

See the minimal reproduction which includes unit tests demonstrating the issue and workarounds.

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

No branches or pull requests

1 participant