Skip to content

Commit d0e4626

Browse files
Merge pull request #14 from mgcostaParedes/ISSUE-12
fix: fixed some inconsistencies on builder & grammar contracts
2 parents 7bb416b + 4bd79a7 commit d0e4626

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/Spanner/Builder/Builder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function getBindings(): array
141141
return Arr::collapse($this->bindings);
142142
}
143143

144-
public function getRawBindings()
144+
public function getRawBindings(): array
145145
{
146146
return $this->bindings;
147147
}
@@ -506,7 +506,7 @@ public function orderByDesc($column): self
506506
public function groupBy(...$groups): self
507507
{
508508
foreach ($groups as $group) {
509-
$this->groups = array_merge((array) $this->groups, Arr::wrap($group));
509+
$this->groups = array_merge((array)$this->groups, Arr::wrap($group));
510510
}
511511

512512
return $this;
@@ -556,6 +556,7 @@ public function cloneWithout(array $properties)
556556
}
557557
});
558558
}
559+
559560
public function cloneWithoutBindings(array $except)
560561
{
561562
return $this->tap($this->clone(), function ($clone) use ($except) {

src/Spanner/Builder/Grammar/Grammatical.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ interface Grammatical
99
public function compile(Builder $query): string;
1010
public function compileUpdate(Builder $query, array $values): string;
1111
public function compileDelete(Builder $query): string;
12+
public function wrapTable($table);
1213
}

src/Spanner/Builder/Grammar/SpannerGrammar.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public function compileDelete(Builder $query): string
6868
);
6969
}
7070

71+
public function wrapTable($table)
72+
{
73+
if (!$this->isExpression($table)) {
74+
return $this->wrap($this->tablePrefix . $table, true);
75+
}
76+
77+
return $table->getValue($table);
78+
}
79+
7180
protected function compileComponents(Builder $query): array
7281
{
7382
$sql = [];
@@ -239,7 +248,7 @@ protected function concatenateWhereClauses($query, $sql): string
239248
return $conjunction . ' ' . $this->removeLeadingBoolean(implode(' ', $sql));
240249
}
241250

242-
private function whereBasic(Builder $query, array $where): string
251+
protected function whereBasic(Builder $query, array $where): string
243252
{
244253
$value = $this->parameter($where);
245254

@@ -316,22 +325,12 @@ protected function concatenate($segments): string
316325
}));
317326
}
318327

319-
public function wrapTable($table)
320-
{
321-
if (! $this->isExpression($table)) {
322-
return $this->wrap($this->tablePrefix . $table, true);
323-
}
324-
325-
return $table->getValue($table);
326-
}
327-
328328
protected function wrap($value, $prefixAlias = false)
329329
{
330330
if ($this->isExpression($value)) {
331331
return $value->getValue($value);
332332
}
333333

334-
335334
if (stripos($value, ' as ') !== false) {
336335
return $this->wrapAliasedValue($value, $prefixAlias);
337336
}

src/Spanner/Builder/Interfaces/Operator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function join($table, $first, $operator = null, $second = null, $type = '
2020

2121
public function where($column, $operator = null, $value = null, $boolean = 'and'): Builder;
2222
public function whereColumn($first, $operator = null, $second = null, $boolean = 'and'): Builder;
23+
public function whereBetween($column, iterable $values, $boolean = 'and', $not = false): Builder;
2324
public function whereNested(Closure $callback, $boolean = 'and'): Builder;
2425
public function addNestedWhereQuery($query, $boolean = 'and'): Builder;
2526
public function orWhere($column, $operator = null, $value = null): Builder;
@@ -46,4 +47,6 @@ public function crossJoin($table, $first = null, $operator = null, $second = nul
4647

4748
public function orderBy($column, $direction = 'asc'): Builder;
4849
public function orderByDesc($column): Builder;
50+
51+
public function groupBy(array ...$groups): Builder;
4952
}

0 commit comments

Comments
 (0)