Skip to content

Commit

Permalink
fix(QueryBuilderAdapter): auto seek method (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi authored Jul 27, 2024
1 parent 7cb2598 commit a68b1db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* chore: cleanup
* feat: native query adapter now supports row values method
* feat: query builder adapter now supports row values method
* fix(`QueryBuilderAdapter`): auto seek method

# 0.15.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,29 @@ private function generateWhereExpression(
return match ($this->seekMethod) {
SeekMethod::Approximated => $this->generateApproximatedWhereExpression($fields),
SeekMethod::RowValues => $this->generateRowValuesWhereExpression($fields),
// SeekMethod::Auto => $this->generateAutoWhereExpression($fields),
default => throw new LogicException('Unsupported seek method'),
SeekMethod::Auto => $this->generateAutoWhereExpression($fields),
};
}

/**
* @param non-empty-list<Field> $fields
* @return array{Andx|string|null,array<string,QueryParameter>}
*/
private function generateAutoWhereExpression(array $fields): array
{
$order = null;

foreach ($fields as $field) {
if ($order === null) {
$order = $field->getOrder();
} elseif ($order !== $field->getOrder()) {
return $this->generateApproximatedWhereExpression($fields);
}
}

return $this->generateRowValuesWhereExpression($fields);
}

/**
* @param non-empty-list<Field> $fields
* @return array{Andx,array<string,QueryParameter>}
Expand Down

0 comments on commit a68b1db

Please sign in to comment.