Skip to content

Commit

Permalink
fix(database): findOne() null query filters (#806)
Browse files Browse the repository at this point in the history
* Revert "fix: missed null parsedQuery case (#805)"

This reverts commit 21628e0.

* fix(database): findOne() null query filters
  • Loading branch information
kon14 authored Nov 21, 2023
1 parent 21628e0 commit 5ba4e74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,17 @@ export class MongooseSchema extends SchemaAdapter<Model<any>> {
populate?: string[];
},
): Promise<any> {
let parsedQuery: Indexable | null = parseQuery(this.parseStringToQuery(query));
parsedQuery = await this.getAuthorizedQuery(
const parsedQuery: Indexable | null = parseQuery(this.parseStringToQuery(query));
const filter = await this.getAuthorizedQuery(
'read',
parsedQuery,
false,
options?.userId,
options?.scope,
);
if (isNil(parsedQuery)) return null;
if (isNil(filter) && !isNil(parsedQuery)) {
return null;
}
let finalQuery = this.model.findOne(parsedQuery!, options?.select);
if (options?.populate !== undefined && options?.populate !== null) {
finalQuery = this.populate(finalQuery, options?.populate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export class SequelizeSchema extends SchemaAdapter<ModelStatic<any>> {
options?.userId,
options?.scope,
);
if (isNil(filter)) {
if (isNil(filter) && !isNil(query)) {
return null;
}
const { filter: parsedFilter, parsingResult } = parseQueryFilter(
Expand Down

0 comments on commit 5ba4e74

Please sign in to comment.