Skip to content

Commit eac4ec7

Browse files
Fixed tests
1 parent 742abc8 commit eac4ec7

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/Query/Grammar.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function compileOptions(array $options): string
2626
if (! empty($optionString)) {
2727
$optionString .= ',';
2828
}
29-
$optionString .= $key.'='.$value;
29+
$optionString .= $key . '=' . $value;
3030
}
3131

3232
return "OPTION ({$optionString})";
@@ -122,18 +122,6 @@ public function prepareBindingsForUpdate(array $bindings, array $values)
122122
return parent::prepareBindingsForUpdate($bindings, $values);
123123
}
124124

125-
protected function whereNull(Builder $query, $where)
126-
{
127-
$columnValue = (string) $this->getValue($where['column']);
128-
if ($this->isJsonSelector($columnValue)) {
129-
[$field, $path] = $this->wrapJsonFieldAndPath($where['column']);
130-
131-
return '(JSON_EXTRACT_JSON('.$field.$path.') IS NULL OR JSON_GET_TYPE(JSON_EXTRACT_JSON('.$field.$path.')) = \'NULL\')';
132-
}
133-
134-
return parent::whereNull($query, $where);
135-
}
136-
137125
/**
138126
* Transforms expressions to their scalar types.
139127
*
@@ -149,16 +137,28 @@ public function getValue($expression)
149137
return $expression;
150138
}
151139

140+
protected function whereNull(Builder $query, $where)
141+
{
142+
$columnValue = (string) $this->getValue($where['column']);
143+
if ($this->isJsonSelector($columnValue)) {
144+
[$field, $path] = $this->wrapJsonFieldAndPath($where['column']);
145+
146+
return '(JSON_EXTRACT_JSON(' . $field . $path . ') IS NULL OR JSON_GET_TYPE(JSON_EXTRACT_JSON(' . $field . $path . ')) = \'NULL\')';
147+
}
148+
149+
return $this->wrap($where['column']) . ' is null';
150+
}
151+
152152
protected function whereNotNull(Builder $query, $where)
153153
{
154154
$columnValue = (string) $this->getValue($where['column']);
155155
if ($this->isJsonSelector($columnValue)) {
156156
[$field, $path] = $this->wrapJsonFieldAndPath($where['column']);
157157

158-
return '(JSON_EXTRACT_JSON('.$field.$path.') IS NOT NULL AND JSON_GET_TYPE(JSON_EXTRACT_JSON('.$field.$path.')) != \'NULL\')';
158+
return '(JSON_EXTRACT_JSON(' . $field . $path . ') IS NOT NULL AND JSON_GET_TYPE(JSON_EXTRACT_JSON(' . $field . $path . ')) != \'NULL\')';
159159
}
160160

161-
return parent::whereNotNull($query, $where);
161+
return $this->wrap($where['column']) . ' is not null';;
162162
}
163163

164164
protected function wrapJsonSelector($value)
@@ -207,7 +207,7 @@ protected function wrapJsonFieldAndPath($column)
207207
return "'$part'";
208208
}, $parts);
209209

210-
$path = count($parts) ? ', '.implode(', ', $parts) : '';
210+
$path = count($parts) ? ', ' . implode(', ', $parts) : '';
211211

212212
return [$field, $path];
213213
}
@@ -220,7 +220,7 @@ protected function wrapJsonFieldAndPath($column)
220220
*/
221221
protected function wrapUnion($sql)
222222
{
223-
return 'SELECT * FROM ('.$sql.')';
223+
return 'SELECT * FROM (' . $sql . ')';
224224
}
225225

226226
/**
@@ -248,7 +248,7 @@ protected function compileUnion(array $union)
248248
{
249249
$conjunction = $union['all'] ? ' union all ' : ' union ';
250250

251-
return $conjunction.'('.$union['query']->toSql().')';
251+
return $conjunction . '(' . $union['query']->toSql() . ')';
252252
}
253253

254254
/**
@@ -267,18 +267,18 @@ public function compileSelect(Builder $query)
267267
}
268268

269269
if (! empty($query->unionOrders) || isset($query->unionLimit) || isset($query->unionOffset)) {
270-
$sql = 'SELECT * FROM ('.$sql.') ';
270+
$sql = 'SELECT * FROM (' . $sql . ') ';
271271

272272
if (! empty($query->unionOrders)) {
273-
$sql .= ' '.$this->compileOrders($query, $query->unionOrders);
273+
$sql .= ' ' . $this->compileOrders($query, $query->unionOrders);
274274
}
275275

276276
if (isset($query->unionLimit)) {
277-
$sql .= ' '.$this->compileLimit($query, $query->unionLimit);
277+
$sql .= ' ' . $this->compileLimit($query, $query->unionLimit);
278278
}
279279

280280
if (isset($query->unionOffset)) {
281-
$sql .= ' '.$this->compileUnionOffset($query, $query->unionOffset);
281+
$sql .= ' ' . $this->compileUnionOffset($query, $query->unionOffset);
282282
}
283283
}
284284

@@ -312,10 +312,10 @@ private function compileOffsetWithLimit($offset, $limit): string
312312
// Add a huge LIMIT clause
313313
if (! isset($limit)) {
314314
// 9223372036854775807 - max 64-bit integer
315-
return ' LIMIT 9223372036854775807 OFFSET '.(int) $offset;
315+
return ' LIMIT 9223372036854775807 OFFSET ' . (int) $offset;
316316
}
317317

318-
return ' OFFSET '.(int) $offset;
318+
return ' OFFSET ' . (int) $offset;
319319
}
320320

321321
/**

0 commit comments

Comments
 (0)