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

findSingleAttributeList does not filter soft-deleted record #2269

Closed
spinachomes opened this issue Jul 20, 2021 · 1 comment
Closed

findSingleAttributeList does not filter soft-deleted record #2269

spinachomes opened this issue Jul 20, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@spinachomes
Copy link
Contributor

spinachomes commented Jul 20, 2021

  @Test
  public void findSingleAttribute() {

    EBasicSoftDelete bean = new EBasicSoftDelete();
    bean.setName("findSingleAttribute");
    DB.save(bean);

    LoggedSqlCollector.start();

    final String name0 = DB.find(EBasicSoftDelete.class)
      .select("name")
      .where().eq("name", "findSingleAttribute")
      .findSingleAttribute();

    List<String> sql0 = LoggedSqlCollector.current();
    assertThat(sql0.get(0)).contains("where t0.name = ? and t0.deleted =");
    assertThat(name0).isEqualTo("findSingleAttribute");

    // now soft delete the bean
    DB.delete(bean);
    List<String> sqlUpdate = LoggedSqlCollector.current();
    assertThat(sqlUpdate.get(0)).contains("update ebasic_sdchild set");

    // use setIncludeSoftDeletes
    final String name1 = DB.find(EBasicSoftDelete.class)
      .select("name")
      .where().eq("name", "findSingleAttribute")
      .setIncludeSoftDeletes()
      .findSingleAttribute();

    List<String> sql1 = LoggedSqlCollector.current();
    assertThat(sql1.get(0)).doesNotContain(" and t0.deleted =");
    assertThat(name1).isEqualTo("findSingleAttribute");


    // not using setIncludeSoftDeletes, so don't find it
    final String name2 = DB.find(EBasicSoftDelete.class)
      .select("name")
      .where().eq("name", "findSingleAttribute")
      .findSingleAttribute();

    List<String> sql2 = LoggedSqlCollector.stop();
    assertThat(sql2.get(0)).contains(" and t0.deleted =");
    assertThat(name2).isNull();
  }
@rbygrave rbygrave self-assigned this Jul 22, 2021
@rbygrave rbygrave added the bug label Jul 22, 2021
@rbygrave rbygrave added this to the 12.10.0 milestone Jul 22, 2021
@rbygrave
Copy link
Member

Thanks for logging the issue @spinachomes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants