Skip to content

Fix range filters, declare Laravel deps, add test suite and CI - #2

Merged
KalimeroMK merged 4 commits into
masterfrom
fix/filter-correctness
Sep 21, 2026
Merged

KalimeroMK merged 4 commits into
masterfrom
fix/filter-correctness

Conversation

@KalimeroMK

Copy link
Copy Markdown
Owner

Two bugs made the documented range filter a no-op

scopeFilter() matched the raw filter key against $fillable, so age_min / age_max were dropped
before reaching the range branch. The README's own example ($fillable = ['name','email','is_active']
with age_min/age_max filters) silently returned unfiltered results.

Working around it by adding age_min to $fillable hit a second bug: rtrim($field, '_min') strips a
character set, not a suffix.

tax_max     -> products.t          (expected products.tax)
domain_min  -> products.doma       (expected products.domain)
max_max     -> ''                  (empty column name)

Range keys now resolve via substr($field, 0, -4) and are matched against $fillable by their base column.

Also in this PR

  • composer.json used Illuminate\* classes without requiring any Laravel package; added
    illuminate/database and illuminate/support (L10/11/12)
  • removed the hardcoded "version": "1.0.0", which overrode the git tags on Packagist
  • removed "minimum-stability": "dev" — it made composer install fail outright
  • boolean fields are now table-qualified like every other condition (they were not, which breaks on joins)
  • strict in_array() comparisons; declare(strict_types=1) and parameter/return types throughout
  • whereLike splits on the last dot, so nested relations (posts.comments.body) work; it no longer
    re-registers if the macro already exists
  • phpunit.xml rewritten for the PHPUnit 11 schema (verbose="true" was removed in PHPUnit 10)
  • untracked .phpunit.result.cache and composer.lock
  • GitHub Actions matrix: PHP 8.2/8.3/8.4 × Laravel 10/11/12, plus Rector

Tests

scopeFilter had no test at all. Added 12 covering exact, LIKE, boolean, whereIn, null handling,
non-fillable rejection, both range operators and the suffix-corruption cases; 7 for the macro including
nested relations. The 5 range tests fail on master and pass here.

19 tests, 20 assertions, green. Rector clean.

One behaviour change to be aware of

applyFieldFilter() is protected and its signature changed (it now takes the resolved column and
operator). Anything overriding it needs updating — unlikely, but it is the only BC-sensitive edit.

scopeFilter dropped every _min/_max key because it checked the raw key
against $fillable, so the documented range filter never ran. When the key
was made fillable, rtrim($field, '_min') stripped a character set rather
than the suffix, turning tax_max into the column t and max_max into an
empty string.

Range keys now resolve to their base column with substr() and are matched
against $fillable by that column. Boolean fields are table-qualified like
every other condition, and in_array() comparisons are strict.

composer.json declared no Laravel packages while using Illuminate classes,
pinned version 1.0.0 over the git tags, and set minimum-stability to dev.
The matrix installed illuminate/* per Laravel version but left
orchestra/testbench unconstrained, so Composer could not resolve a
matching testbench and every Laravel 10 and 11 job failed.

Laravel 10 and 11 are both past their security-support window, so every
release carries an advisory and Composer refuses to install them. Laravel
10 is dropped; Laravel 11 is kept and tested with the advisory block
lifted in the workflow only.
PHP 8.1 is only reachable through Laravel 10, so illuminate/* is widened
back to ^10.0 and the matrix covers 8.1 through 8.5.

Testbench 8 defaults to the mysql connection, unlike 9 and 10 which
default to in-memory sqlite, so every test errored with 'could not find
driver' on Laravel 10. The test case now declares the sqlite connection
explicitly instead of relying on the default.

The CI install step also moved orchestra/testbench out of require-dev by
requiring it without --dev.
Laravel 13.32.0 was released on 2026-09-15 and requires PHP ^8.3, paired
with orchestra/testbench 11. The suite passes against it unchanged.

The audit-block exception now names Laravel 10 and 11 explicitly instead
of excluding 12, which would have lifted it for 13 as well.
@KalimeroMK
KalimeroMK merged commit dd41ebc into master Sep 21, 2026
12 checks passed
@KalimeroMK
KalimeroMK deleted the fix/filter-correctness branch September 21, 2026 09:01
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