mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-01 19:27:39 +08:00
Fixed bug that sortByMany
value is null when using SORT_NATURAL
(#7124)
This commit is contained in:
parent
cc61a3602f
commit
f6dabc8889
@ -7,6 +7,10 @@
|
||||
- [#7071](https://github.com/hyperf/hyperf/pull/7071) Added `Hyperf\Database\Schema\Blueprint::tinyText()`.
|
||||
- [#7110](https://github.com/hyperf/hyperf/pull/7110) Added support for disallowing class morphs.
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#7124](https://github.com/hyperf/hyperf/pull/7124) Fixed bug that `sortByMany` value is null when using `SORT_NATURAL`.
|
||||
|
||||
# v3.1.43 - 2024-10-10
|
||||
|
||||
## Fixed
|
||||
|
@ -1616,7 +1616,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl
|
||||
$result = match ($options) {
|
||||
SORT_NUMERIC => intval($values[0]) <=> intval($values[1]),
|
||||
SORT_STRING => strcmp($values[0], $values[1]),
|
||||
SORT_NATURAL => strnatcmp($values[0], $values[1]),
|
||||
SORT_NATURAL => strnatcmp((string) $values[0], (string) $values[1]),
|
||||
SORT_LOCALE_STRING => strcoll($values[0], $values[1]),
|
||||
default => $values[0] <=> $values[1],
|
||||
};
|
||||
|
@ -1341,5 +1341,16 @@ class CollectionTest extends TestCase
|
||||
'd' => ['id' => 4, 'name' => 'd'],
|
||||
'e' => ['id' => 5, 'name' => 'e'],
|
||||
]), (string) $dataMany);
|
||||
|
||||
$dataManyNull = (new $collection(
|
||||
[
|
||||
['id' => 2, 'name' => 'b'],
|
||||
['id' => 1, 'name' => null],
|
||||
]
|
||||
))->sortBy([['id', 'desc'], ['name', 'desc']], SORT_NATURAL);
|
||||
$this->assertEquals(json_encode([
|
||||
['id' => 2, 'name' => 'b'],
|
||||
['id' => 1, 'name' => null],
|
||||
]), json_encode($dataManyNull));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user