Skip to content

Commit b54e401

Browse files
committed
wip
1 parent 31a6ff8 commit b54e401

File tree

9 files changed

+595
-228
lines changed

9 files changed

+595
-228
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- **BREAKING**: Fixed critical bug in `whereProperty` comparison operators where column type was incorrectly determined by search value type instead of property definition type
12+
- **BREAKING**: Updated `scopeWhereProperty` parameter order to `($query, $name, $operator = '=', $value = null)` for consistency with Laravel conventions
13+
- Fixed inconsistent behavior when searching properties with mixed value types (e.g., searching numeric properties with string values)
14+
1015
### Added
1116
- Support for Laravel 11
1217
- Enhanced PostgreSQL JSONB support

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@ A dynamic property system for Laravel that allows any entity (users, companies,
1717
- **Database Agnostic**: Works with MySQL and SQLite
1818
- **Validation**: Built-in property validation with custom rules
1919

20+
## Upgrading
21+
22+
### From v1.x to v2.x
23+
24+
**Breaking Change: `whereProperty` Parameter Order**
25+
26+
The parameter order for `whereProperty` has changed to be consistent with Laravel conventions:
27+
28+
```php
29+
// Old (v1.x) - DEPRECATED
30+
User::whereProperty('age', 25, '>')->get();
31+
32+
// New (v2.x) - CORRECT
33+
User::whereProperty('age', '>', 25)->get();
34+
35+
// For equality comparisons, both work:
36+
User::whereProperty('status', 'active')->get(); // Still works
37+
User::whereProperty('status', '=', 'active')->get(); // Also works
38+
```
39+
40+
**Why this change was necessary:** The previous implementation had a critical bug where comparison operators gave inconsistent results because the system determined which database column to search based on the search value's type rather than the property definition's type. This caused queries like `whereProperty('level', '>', '3')` vs `whereProperty('level', '>', 3)` to search different columns and return different results.
41+
42+
**Migration:** Update all your `whereProperty` calls that use operators to put the operator before the value:
43+
- `whereProperty($name, $value, $operator)``whereProperty($name, $operator, $value)`
44+
2045
## Installation
2146

2247
Install the package via Composer:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
},
1616
"require": {
1717
"php": "^8.3",
18-
"illuminate/database": "^10.0|^11.0|^12.0",
19-
"illuminate/support": "^10.0|^11.0|^12.0"
18+
"illuminate/database": "^11.0|^12.0",
19+
"illuminate/support": "^11.0|^12.0"
2020
},
2121
"require-dev": {
2222
"laravel/pint": "^1.24",
23-
"orchestra/testbench": "^8.0|^9.0",
23+
"orchestra/testbench": "^9.0|^10.0",
2424
"pestphp/pest": "^4.0"
2525
},
2626
"extra": {

0 commit comments

Comments
 (0)