-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Global Filter is ignored when using Query Builder #3009
Comments
Yes, because filters are only handled by EM, with QB things need to be explicit. |
@B4nan Hey! Is there any workaround for auto filters when using filters? (Because not all queries are available with EM.find) |
Not tested, but something like this might work: const qb = ...;
const filters = em.applyFilters('EntityName', {}, {}, 'read');
qb.andWhere(filters); |
@B4nan, Is there any way to get global filters from EM and apply them to QB? Or maybe an option on |
Its a sync method, to apply filters you need async context as they can be async. You can use |
Yeah, I ended up doing that. |
I see, looks like the regular filters work, but not the filters on relations. |
I will wait for your repro, but after spending a few hours looking into the count and filters problem, I feel like it actually works correctly. Filters on relations are not considered for the where condition (unless you use |
Describe the bug
It seems the "applyFilters" logic that happens when using EntityManager.find does not appear to exist when using the query builder.
Stack trace
To Reproduce
Steps to reproduce the behavior:
orm.em.addFilter("tenant",(args: any) => ({}))
await orm.em.createQueryBuilder(ModelToFilterWithGlobalFilter).getResultList()
Expected behavior
Same behavior as EntityManager.find
Additional context
const temp = await orm.em.createQueryBuilder(TModel).getResultList(); // does not fire global filter
const temp2 = await orm.em.find(TModel, {}); //does fire global filter
Versions
The text was updated successfully, but these errors were encountered: