Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit ac74cd5

Browse files
Merge pull request #10 from aloware/fix/conditions-sanity-check
Fix | Add Sanity Check
2 parents cefd4d8 + bf1ad9f commit ac74cd5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/CursorPaginator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,11 @@ protected function overrideCursorCondition( $builder , string $full_identifier_n
654654

655655
$bindings = $query->getBindings();
656656

657-
if($query->wheres[count($query->wheres)-1]['column'] == $full_identifier_name) {
658-
$query->wheres[count($query->wheres)-1]['value'] = $next_cursor_value;
657+
$index = count($query->wheres) - 1;
658+
659+
// Sanity check and make sure current where column is the same as cursor column
660+
if(isset($query->wheres[$index]['column']) && $query->wheres[$index]['column'] == $full_identifier_name) {
661+
$query->wheres[$index]['value'] = $next_cursor_value;
659662
$bindings[count($bindings)-1] = $next_cursor_value;
660663
} else {
661664
$query->where($full_identifier_name, $identifier_sort_inverted ? '<' : '>', $next_cursor_value);

0 commit comments

Comments
 (0)