Skip to content

prevent query error on scoped entity when filter=W10=#2

Open
westwoodworm wants to merge 3 commits intomainfrom
query-filter-fix
Open

prevent query error on scoped entity when filter=W10=#2
westwoodworm wants to merge 3 commits intomainfrom
query-filter-fix

Conversation

@westwoodworm
Copy link
Contributor

@westwoodworm westwoodworm commented Jan 2, 2024

The filter param has no validation so prone to have errors. When the Model/paginate method calls self::findAll with 1st argument $paginator->filters() as default value empty array, it will then be serialized to 'W10=' which will lead to a query error. Or else this should be avoided when passing the api params.

@mermetbt
Copy link
Contributor

mermetbt commented Jan 2, 2024

This MR has no explanation.

@westwoodworm
Copy link
Contributor Author

westwoodworm commented Jan 10, 2024

Added a query validator to avoid invalid filter caused errors.
image


if ($field instanceof QueryBuilder) {
if (empty($field->build())) return $this;
$this->append($globalOperator, $field->build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you build twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants