Skip to content

Commit 44e9f2b

Browse files
committed
Refactor where clause parsing
1 parent 9e1905b commit 44e9f2b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Diff for: src/CachedBuilder.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,15 @@ protected function getQueryColumns(array $columns) : string
7474
protected function getWhereClauses() : string
7575
{
7676
return collect($this->query->wheres)->reduce(function ($carry, $where) {
77-
if (! $where['column'] ?? false) {
78-
return $carry . '';
79-
}
80-
81-
$value = $where['value'] ?? '';
77+
$value = array_get($where, 'value');
8278

83-
if ($where['values'] ?? false) {
84-
$value .= 'in_' . implode('_', $where['values']);
79+
if (in_array($where['type'], ['In', 'Null', 'NotNull'])) {
80+
$value = strtolower($where['type']);
8581
}
8682

87-
$value = $where['type'] === 'Null' ? 'null' : $value;
88-
$value = $where['type'] === 'NotNull' ? 'notnull' : $value;
83+
if (is_array(array_get($where, 'values'))) {
84+
$value .= '_' . implode('_', $where['values']);
85+
}
8986

9087
return "{$carry}-{$where['column']}_{$value}";
9188
}) ?: '';

0 commit comments

Comments
 (0)