Skip to content

Commit

Permalink
Fixed validation of class inheritance in queries (#7789)
Browse files Browse the repository at this point in the history
* Fixed validation of class inheritance in queries

Signed-off-by: Victor Ilyushchenko <[email protected]>

* added mixin check

Co-authored-by: Denis Bykhov <[email protected]>
Signed-off-by: Victor Ilyushchenko <[email protected]>

---------

Signed-off-by: Victor Ilyushchenko <[email protected]>
Co-authored-by: Denis Bykhov <[email protected]>
  • Loading branch information
mr1name and BykhovDenis authored Jan 27, 2025
1 parent e950ee4 commit 83a912d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ export function matchQuery<T extends Doc> (
hierarchy: Hierarchy,
skipLookup: boolean = false
): Doc[] {
let result = docs
const baseClass = hierarchy.getBaseClass(clazz)
let result = docs.filter((r) => hierarchy.isDerived(r._class, baseClass))
if (baseClass !== clazz) {
result = docs.filter((r) => hierarchy.hasMixin(r, clazz))
}
for (const key in query) {
if (skipLookup && key.startsWith('$lookup.')) {
continue
Expand Down

0 comments on commit 83a912d

Please sign in to comment.