Skip to content

fix(core): Allow database filter condition to have binds - #129

Closed
mcaskill wants to merge 1 commit into
mainfrom
mcaskill/database-filter-condition-binds
Closed

mcaskill wants to merge 1 commit into
mainfrom
mcaskill/database-filter-condition-binds

Conversation

@mcaskill

Copy link
Copy Markdown
Collaborator

Primarily useful for subqueries built from another DatabaseSource.

$articles = $this->getArticleRepository()->source();
$categories->addFilter([
    'condition' => sprintf('objTable.`id` IN (%s)', $articles->sqlLoad()),
    'binds'     => $articles->filterBinds(),
]);

Previously, a Filter’s binds are reset and rebuilt only when DatabaseFilter::sql() is called.

This proposal rearranges the logic to preserve a Filter’s predefined binds if the Filter is an active Condition or the Filter is inactive. Otherwise, reset and rebuild the binds form the sub-Filters or Fields.

Primarily useful for subqueries built from another `DatabaseSource`.

```php
$articles = $this->getArticleRepository()->source();
$categories->addFilter([
    'condition' => sprintf('objTable.`id` IN (%s)', $articles->sqlLoad()),
    'binds'     => $articles->filterBinds(),
]);
```

Introduced in v5.1.5, a Filter’s binds are reset and rebuilt only when `DatabaseFilter::sql()` is called.

This commit rearranges the logic to preserve a Filter’s predefined binds if its an active Condition or inactive. Otherwise, reset and rebuild the binds form the sub-Filters or Fields.
@mcaskill mcaskill closed this Sep 28, 2026
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.

1 participant