Repository navigation
Fix scoped state and add Vitess analytical queries #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 0.4
Are you sure you want to change the base?
Changes from all commits
2e12a71
1431fbe
20f1595
4056b4f
ea9524f
fb0beed
101f2f8
bd22992
b0e13d9
4a0d19f
ff769f8
e20539c
5a34968
f2460e2
01ccb0a
ebc223d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -508,6 +508,8 @@ protected function paginateUsingCursor( | |
| } | ||
|
|
||
| $orders = $this->ensureOrderForCursorPagination(! is_null($cursor) && $cursor->pointsToPreviousItems()); | ||
| $this->limit($perPage + 1); | ||
| $builder = $this; | ||
|
|
||
| if (! is_null($cursor)) { | ||
| $query = $this instanceof Builder ? $this->getQuery() : $this; | ||
|
|
@@ -525,6 +527,7 @@ protected function paginateUsingCursor( | |
| $query->columns = $originalColumns; | ||
| } | ||
|
|
||
| $builder = $this->getBuilderForCursorPage(); | ||
| $comparisons = []; | ||
| $bindings = []; | ||
| foreach ($orders as $order) { | ||
|
|
@@ -533,23 +536,35 @@ protected function paginateUsingCursor( | |
| $order['original'] = $original !== $column && Str::contains($original, ['(', ')']) | ||
| ? new Expression($original) : $original; | ||
| $comparisons[] = $order; | ||
| $bindings[$column] = $this->getCursorParameterBinding($cursor, $column); | ||
| $bindings[$column] = $builder->getCursorParameterBinding($cursor, $column); | ||
| } | ||
|
|
||
| // Members are resolved by their output positions during SELECT preparation; | ||
| // keep their select/join bindings and never rewrite a shared union builder. | ||
| $query->addCursorPaginationConditions($comparisons, $bindings); | ||
| } | ||
|
|
||
| $this->limit($perPage + 1); | ||
| $pageQuery = $builder instanceof Builder ? $builder->getQuery() : $builder; | ||
| if ($pageQuery !== $query) { | ||
| // Keep the caller's page conditions as well as the scoped execution copy's. | ||
| $pageQuery->addCursorPaginationConditions($comparisons, $bindings); | ||
| } | ||
| } | ||
|
|
||
| return $this->cursorPaginator($this->get($columns), $perPage, $cursor, [ | ||
| return $this->cursorPaginator($builder->get($columns), $perPage, $cursor, [ | ||
| 'path' => Paginator::resolveCurrentPath(), | ||
| 'cursorName' => $cursorName, | ||
| 'parameters' => $orders->pluck('column')->toArray(), | ||
| ]); | ||
| } | ||
|
|
||
| /** | ||
| * Get the builder that owns cursor binding and page execution. | ||
| */ | ||
| protected function getBuilderForCursorPage(): static | ||
| { | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Get a cursor parameter for database binding. | ||
| */ | ||
|
|
@@ -565,15 +580,15 @@ protected function getCursorParameterBinding(Cursor $cursor, string $parameter): | |
| */ | ||
| protected function getOriginalColumnNameForCursorPagination(QueryBuilder|Builder $builder, string $parameter): string | ||
| { | ||
| $columns = $builder instanceof Builder ? $builder->getQuery()->getColumns() : $builder->getColumns(); | ||
| $query = $builder instanceof Builder ? $builder->getQuery() : $builder; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| foreach ($columns as $column) { | ||
| foreach ($query->getColumns() as $column) { | ||
| if (($position = strripos($column, ' as ')) !== false) { | ||
| $original = substr($column, 0, $position); | ||
|
|
||
| $alias = substr($column, $position + 4); | ||
|
|
||
| if ($parameter === $alias || $builder->getGrammar()->wrap($parameter) === $alias) { | ||
| if ($parameter === $alias || $query->getGrammar()->wrap($parameter) === $alias) { | ||
| return $original; | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.