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

SoftDelete predicate missing on join to ManyToOne supporting predicate expression #2145

Closed
rbygrave opened this issue Jan 19, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@rbygrave
Copy link
Member

I want to find child by parent bean which using @SoftDelete.

This is example.

    @Test
    public void testParentJoinWithSoftDelete() {
        EBasicSoftDelete bean = new EBasicSoftDelete();
        bean.setName("Joined with deleted false");
        DB.save(bean);
        final EBasicSDChild child = new EBasicSDChild(bean, "Find me from parent name", 1L);
        DB.save(child);
        
        Query<EBasicSDChild> query = DB.find(EBasicSDChild.class).where().eq("owner.name",
            "Joined with deleted false").query();
        
        List<EBasicSDChild> list = query.findList();
        // Make sure that query includes the soft delete join predicates
        assertSql(query).contains("t1.deleted = false");
        assertThat(list).hasSize(1);
        
        // Cleanup created entity
        query.delete();
        DB.deleteAllPermanent(singletonList(child));
        DB.deleteAllPermanent(singletonList(bean));
    }

I expect

select t0.id, t0.child_name, t0.amount, t0.version, t0.deleted, t0.owner_id 
from ebasic_sdchild t0 
join ebasic_soft_delete t1 on t1.id = t0.owner_id and t1.deleted = false 
where t1.name = ? and t0.deleted = false

but, actually

select t0.id, t0.child_name, t0.amount, t0.version, t0.deleted, t0.owner_id 
from ebasic_sdchild t0 
join ebasic_soft_delete t1 on t1.id = t0.owner_id  
where t1.name = ? and t0.deleted = false

Is this expected behavior?

Thanks.


No, this is a bug.

@rbygrave rbygrave added the bug label Jan 19, 2021
@rbygrave rbygrave self-assigned this Jan 19, 2021
@rbygrave
Copy link
Member Author

So this is specifically on joins that are added to support query expressions - "extra joins" as opposed to joins added to support fetching.

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

1 participant