Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
245cb65
Fix for issue #35. Corrected ActiveRecordTest's so that capitalizatio…
ipundit Aug 31, 2023
e1bb78f
Primary key has to be lowercased too because gettter/setters are lowe…
ipundit Aug 31, 2023
f6e2981
Fix for issue #35. Corrected ActiveRecordTest's so that capitalizatio…
ipundit Aug 31, 2023
67471f5
Primary key has to be lowercased too because gettter/setters are lowe…
ipundit Aug 31, 2023
83a4db0
Merge branch 'master' of https://github.com/ipundit/activerecord
ipundit Sep 1, 2023
1aea4e1
Merge branch 'master' into master
ipundit Sep 1, 2023
9639f31
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 2, 2023
52478ab
Running all the tests may take more than the default of 300 seconds. …
ipundit Sep 2, 2023
c323677
Write proper tests that demonstrate the fix for issue #35:
ipundit Sep 2, 2023
80ed052
Switched from firstName field to existing mixedCaseField to pass Post…
ipundit Sep 2, 2023
b8ecfc0
- List things in alphabetical order
ipundit Sep 2, 2023
23d00a7
Revert updates to test suite as ActiveRecordTest::test_case_insensiti…
ipundit Sep 2, 2023
e31ec4f
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 2, 2023
9a6fb32
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 2, 2023
ba7f090
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 4, 2023
d42a7d1
Implemented composer test <fileName> <filter>
ipundit Sep 4, 2023
fc79d97
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 4, 2023
568cfb5
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 4, 2023
650d368
Fix style issues
ipundit Sep 4, 2023
767e537
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 4, 2023
089d3d3
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 5, 2023
2eec6b0
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 5, 2023
6aba443
Fix for issue #55
ipundit Sep 5, 2023
c772578
Remove unused scripts and files references.
ipundit Sep 5, 2023
8291ea6
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 5, 2023
cf6056e
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 5, 2023
64e45b8
Remove unused items in composer.json
ipundit Sep 5, 2023
1dcad8d
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 5, 2023
7b1e20e
Merge branch 'master' of https://github.com/ipundit/activerecord
ipundit Sep 5, 2023
79d2182
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 5, 2023
1b822b4
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 6, 2023
6bd01fd
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 13, 2023
09f0732
Document composer style-fix
ipundit Sep 14, 2023
7993fc0
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 15, 2023
7080716
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 16, 2023
123d0f5
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 18, 2023
99a7541
Support dynamic finders in Relation so that Author::select('author_id…
ipundit Sep 18, 2023
75387d8
- Moved FindBy and From tests from ActiveRecordFindTest.php to Active…
ipundit Sep 18, 2023
fc5e51a
Fix imports to pass regression.
ipundit Sep 18, 2023
375947b
Improve code coverage in Model
ipundit Sep 18, 2023
9177884
Cleanup as per code review
ipundit Sep 18, 2023
41ab61f
Fixed two bugs and wrote test cases to illuminate them:
ipundit Sep 18, 2023
94cb360
Fixed a bug: Calling find_by(), first(), last(), and take() should no…
ipundit Sep 18, 2023
c979ab4
Removed an extraneous line
ipundit Sep 18, 2023
b77a738
Added tests for Book::not('book_id in (?)', [1])
ipundit Sep 18, 2023
06b40bb
Style fix
ipundit Sep 18, 2023
f1a8e8e
Merge branch 'master' of https://github.com/php-activerecord/activere…
ipundit Sep 19, 2023
a860128
Fixed a bug due to the misunderstanding of what first() and last() do…
ipundit Sep 19, 2023
ab321f3
Small style-fix
ipundit Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,10 @@ private function firstOrLast(int $limit = null, bool $isAscending): array
$pk = $this->table()->pk;
if (!empty($pk)) {
if (array_key_exists('order', $options)) {
$reverseCommand = $isAscending ? 'DESC' : 'ASC';

if (str_contains($options['order'], implode(" {$reverseCommand}, ", $this->table()->pk) . " {$reverseCommand}")) {
$options['order'] = SQLBuilder::reverse_order((string) $options['order']);
if (!$isAscending) {
if (str_contains($options['order'], implode(' DESC, ', $this->table()->pk) . ' DESC')) {
$options['order'] = SQLBuilder::reverse_order((string) $options['order']);
}
}
} elseif (!array_key_exists('having', $options)) {
$command = $isAscending ? 'ASC' : 'DESC';
Expand Down
3 changes: 2 additions & 1 deletion test/ActiveRecordFirstLastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public function testLastWithCountOverridesLimit()
public function testDoesNotClobberOrderOrLimit()
{
$rel = Author::limit(2)->order('author_id DESC');
$this->assertEquals(1, $rel->first()->author_id);
$this->assertEquals(Author::last(), $rel->first());
$this->assertEquals(Author::first(), $rel->last());

$authors = $rel->to_a();
$this->assertEquals(2, count($authors));
Expand Down