Skip to content

Commit 7749d64

Browse files
authored
[10.x] Allow expressions in query builder (#46160)
* Allow expressions for where's * Allow expressions for aggregates * Bring back missing spaces * Use FQN for class type hints * Allow expressions for join tables
1 parent ad021d8 commit 7749d64

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

src/Illuminate/Database/Query/Builder.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public function ignoreIndex($index)
508508
/**
509509
* Add a join clause to the query.
510510
*
511-
* @param string $table
511+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
512512
* @param \Closure|string $first
513513
* @param string|null $operator
514514
* @param string|null $second
@@ -548,7 +548,7 @@ public function join($table, $first, $operator = null, $second = null, $type = '
548548
/**
549549
* Add a "join where" clause to the query.
550550
*
551-
* @param string $table
551+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
552552
* @param \Closure|string $first
553553
* @param string $operator
554554
* @param string $second
@@ -588,7 +588,7 @@ public function joinSub($query, $as, $first, $operator = null, $second = null, $
588588
/**
589589
* Add a left join to the query.
590590
*
591-
* @param string $table
591+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
592592
* @param \Closure|string $first
593593
* @param string|null $operator
594594
* @param string|null $second
@@ -602,7 +602,7 @@ public function leftJoin($table, $first, $operator = null, $second = null)
602602
/**
603603
* Add a "join where" clause to the query.
604604
*
605-
* @param string $table
605+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
606606
* @param \Closure|string $first
607607
* @param string $operator
608608
* @param string $second
@@ -631,7 +631,7 @@ public function leftJoinSub($query, $as, $first, $operator = null, $second = nul
631631
/**
632632
* Add a right join to the query.
633633
*
634-
* @param string $table
634+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
635635
* @param \Closure|string $first
636636
* @param string|null $operator
637637
* @param string|null $second
@@ -645,7 +645,7 @@ public function rightJoin($table, $first, $operator = null, $second = null)
645645
/**
646646
* Add a "right join where" clause to the query.
647647
*
648-
* @param string $table
648+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
649649
* @param \Closure|string $first
650650
* @param string $operator
651651
* @param string $second
@@ -674,7 +674,7 @@ public function rightJoinSub($query, $as, $first, $operator = null, $second = nu
674674
/**
675675
* Add a "cross join" clause to the query.
676676
*
677-
* @param string $table
677+
* @param string|\Illuminate\Contracts\Database\Query\Expression $table
678678
* @param \Closure|string|null $first
679679
* @param string|null $operator
680680
* @param string|null $second
@@ -745,7 +745,7 @@ public function mergeWheres($wheres, $bindings)
745745
/**
746746
* Add a basic where clause to the query.
747747
*
748-
* @param \Closure|string|array $column
748+
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
749749
* @param mixed $operator
750750
* @param mixed $value
751751
* @param string $boolean
@@ -924,7 +924,7 @@ protected function isBitwiseOperator($operator)
924924
/**
925925
* Add an "or where" clause to the query.
926926
*
927-
* @param \Closure|string|array $column
927+
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
928928
* @param mixed $operator
929929
* @param mixed $value
930930
* @return $this
@@ -941,7 +941,7 @@ public function orWhere($column, $operator = null, $value = null)
941941
/**
942942
* Add a basic "where not" clause to the query.
943943
*
944-
* @param \Closure|string|array $column
944+
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
945945
* @param mixed $operator
946946
* @param mixed $value
947947
* @param string $boolean
@@ -961,7 +961,7 @@ public function whereNot($column, $operator = null, $value = null, $boolean = 'a
961961
/**
962962
* Add an "or where not" clause to the query.
963963
*
964-
* @param \Closure|string|array $column
964+
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
965965
* @param mixed $operator
966966
* @param mixed $value
967967
* @return $this
@@ -1053,7 +1053,7 @@ public function orWhereRaw($sql, $bindings = [])
10531053
/**
10541054
* Add a "where in" clause to the query.
10551055
*
1056-
* @param string $column
1056+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
10571057
* @param mixed $values
10581058
* @param string $boolean
10591059
* @param bool $not
@@ -1098,7 +1098,7 @@ public function whereIn($column, $values, $boolean = 'and', $not = false)
10981098
/**
10991099
* Add an "or where in" clause to the query.
11001100
*
1101-
* @param string $column
1101+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
11021102
* @param mixed $values
11031103
* @return $this
11041104
*/
@@ -1110,7 +1110,7 @@ public function orWhereIn($column, $values)
11101110
/**
11111111
* Add a "where not in" clause to the query.
11121112
*
1113-
* @param string $column
1113+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
11141114
* @param mixed $values
11151115
* @param string $boolean
11161116
* @return $this
@@ -1123,7 +1123,7 @@ public function whereNotIn($column, $values, $boolean = 'and')
11231123
/**
11241124
* Add an "or where not in" clause to the query.
11251125
*
1126-
* @param string $column
1126+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
11271127
* @param mixed $values
11281128
* @return $this
11291129
*/
@@ -1200,7 +1200,7 @@ public function orWhereIntegerNotInRaw($column, $values)
12001200
/**
12011201
* Add a "where null" clause to the query.
12021202
*
1203-
* @param string|array $columns
1203+
* @param string|array|\Illuminate\Contracts\Database\Query\Expression $columns
12041204
* @param string $boolean
12051205
* @param bool $not
12061206
* @return $this
@@ -1219,7 +1219,7 @@ public function whereNull($columns, $boolean = 'and', $not = false)
12191219
/**
12201220
* Add an "or where null" clause to the query.
12211221
*
1222-
* @param string|array $column
1222+
* @param string|array|\Illuminate\Contracts\Database\Query\Expression $column
12231223
* @return $this
12241224
*/
12251225
public function orWhereNull($column)
@@ -1230,7 +1230,7 @@ public function orWhereNull($column)
12301230
/**
12311231
* Add a "where not null" clause to the query.
12321232
*
1233-
* @param string|array $columns
1233+
* @param string|array|\Illuminate\Contracts\Database\Query\Expression $columns
12341234
* @param string $boolean
12351235
* @return $this
12361236
*/
@@ -1266,7 +1266,7 @@ public function whereBetween($column, iterable $values, $boolean = 'and', $not =
12661266
/**
12671267
* Add a where between statement using columns to the query.
12681268
*
1269-
* @param string $column
1269+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
12701270
* @param array $values
12711271
* @param string $boolean
12721272
* @param bool $not
@@ -1284,7 +1284,7 @@ public function whereBetweenColumns($column, array $values, $boolean = 'and', $n
12841284
/**
12851285
* Add an or where between statement to the query.
12861286
*
1287-
* @param string $column
1287+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
12881288
* @param iterable $values
12891289
* @return $this
12901290
*/
@@ -1296,7 +1296,7 @@ public function orWhereBetween($column, iterable $values)
12961296
/**
12971297
* Add an or where between statement using columns to the query.
12981298
*
1299-
* @param string $column
1299+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13001300
* @param array $values
13011301
* @return $this
13021302
*/
@@ -1308,7 +1308,7 @@ public function orWhereBetweenColumns($column, array $values)
13081308
/**
13091309
* Add a where not between statement to the query.
13101310
*
1311-
* @param string $column
1311+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13121312
* @param iterable $values
13131313
* @param string $boolean
13141314
* @return $this
@@ -1321,7 +1321,7 @@ public function whereNotBetween($column, iterable $values, $boolean = 'and')
13211321
/**
13221322
* Add a where not between statement using columns to the query.
13231323
*
1324-
* @param string $column
1324+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13251325
* @param array $values
13261326
* @param string $boolean
13271327
* @return $this
@@ -1334,7 +1334,7 @@ public function whereNotBetweenColumns($column, array $values, $boolean = 'and')
13341334
/**
13351335
* Add an or where not between statement to the query.
13361336
*
1337-
* @param string $column
1337+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13381338
* @param iterable $values
13391339
* @return $this
13401340
*/
@@ -1346,7 +1346,7 @@ public function orWhereNotBetween($column, iterable $values)
13461346
/**
13471347
* Add an or where not between statement using columns to the query.
13481348
*
1349-
* @param string $column
1349+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13501350
* @param array $values
13511351
* @return $this
13521352
*/
@@ -1358,7 +1358,7 @@ public function orWhereNotBetweenColumns($column, array $values)
13581358
/**
13591359
* Add an "or where not null" clause to the query.
13601360
*
1361-
* @param string $column
1361+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13621362
* @return $this
13631363
*/
13641364
public function orWhereNotNull($column)
@@ -1369,7 +1369,7 @@ public function orWhereNotNull($column)
13691369
/**
13701370
* Add a "where date" statement to the query.
13711371
*
1372-
* @param string $column
1372+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13731373
* @param string $operator
13741374
* @param \DateTimeInterface|string|null $value
13751375
* @param string $boolean
@@ -1393,7 +1393,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
13931393
/**
13941394
* Add an "or where date" statement to the query.
13951395
*
1396-
* @param string $column
1396+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
13971397
* @param string $operator
13981398
* @param \DateTimeInterface|string|null $value
13991399
* @return $this
@@ -1410,7 +1410,7 @@ public function orWhereDate($column, $operator, $value = null)
14101410
/**
14111411
* Add a "where time" statement to the query.
14121412
*
1413-
* @param string $column
1413+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
14141414
* @param string $operator
14151415
* @param \DateTimeInterface|string|null $value
14161416
* @param string $boolean
@@ -1434,7 +1434,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
14341434
/**
14351435
* Add an "or where time" statement to the query.
14361436
*
1437-
* @param string $column
1437+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
14381438
* @param string $operator
14391439
* @param \DateTimeInterface|string|null $value
14401440
* @return $this
@@ -1451,7 +1451,7 @@ public function orWhereTime($column, $operator, $value = null)
14511451
/**
14521452
* Add a "where day" statement to the query.
14531453
*
1454-
* @param string $column
1454+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
14551455
* @param string $operator
14561456
* @param \DateTimeInterface|string|int|null $value
14571457
* @param string $boolean
@@ -1479,7 +1479,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
14791479
/**
14801480
* Add an "or where day" statement to the query.
14811481
*
1482-
* @param string $column
1482+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
14831483
* @param string $operator
14841484
* @param \DateTimeInterface|string|int|null $value
14851485
* @return $this
@@ -1496,7 +1496,7 @@ public function orWhereDay($column, $operator, $value = null)
14961496
/**
14971497
* Add a "where month" statement to the query.
14981498
*
1499-
* @param string $column
1499+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
15001500
* @param string $operator
15011501
* @param \DateTimeInterface|string|int|null $value
15021502
* @param string $boolean
@@ -1524,7 +1524,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
15241524
/**
15251525
* Add an "or where month" statement to the query.
15261526
*
1527-
* @param string $column
1527+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
15281528
* @param string $operator
15291529
* @param \DateTimeInterface|string|int|null $value
15301530
* @return $this
@@ -1541,7 +1541,7 @@ public function orWhereMonth($column, $operator, $value = null)
15411541
/**
15421542
* Add a "where year" statement to the query.
15431543
*
1544-
* @param string $column
1544+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
15451545
* @param string $operator
15461546
* @param \DateTimeInterface|string|int|null $value
15471547
* @param string $boolean
@@ -1565,7 +1565,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
15651565
/**
15661566
* Add an "or where year" statement to the query.
15671567
*
1568-
* @param string $column
1568+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
15691569
* @param string $operator
15701570
* @param \DateTimeInterface|string|int|null $value
15711571
* @return $this
@@ -1583,7 +1583,7 @@ public function orWhereYear($column, $operator, $value = null)
15831583
* Add a date based (year, month, day, time) statement to the query.
15841584
*
15851585
* @param string $type
1586-
* @param string $column
1586+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
15871587
* @param string $operator
15881588
* @param mixed $value
15891589
* @param string $boolean
@@ -1647,7 +1647,7 @@ public function addNestedWhereQuery($query, $boolean = 'and')
16471647
/**
16481648
* Add a full sub-select to the query.
16491649
*
1650-
* @param string $column
1650+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
16511651
* @param string $operator
16521652
* @param \Closure $callback
16531653
* @param string $boolean
@@ -3094,7 +3094,7 @@ public function doesntExistOr(Closure $callback)
30943094
/**
30953095
* Retrieve the "count" result of the query.
30963096
*
3097-
* @param string $columns
3097+
* @param string|\Illuminate\Contracts\Database\Query\Expression $columns
30983098
* @return int
30993099
*/
31003100
public function count($columns = '*')
@@ -3105,7 +3105,7 @@ public function count($columns = '*')
31053105
/**
31063106
* Retrieve the minimum value of a given column.
31073107
*
3108-
* @param string $column
3108+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
31093109
* @return mixed
31103110
*/
31113111
public function min($column)
@@ -3116,7 +3116,7 @@ public function min($column)
31163116
/**
31173117
* Retrieve the maximum value of a given column.
31183118
*
3119-
* @param string $column
3119+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
31203120
* @return mixed
31213121
*/
31223122
public function max($column)
@@ -3127,7 +3127,7 @@ public function max($column)
31273127
/**
31283128
* Retrieve the sum of the values of a given column.
31293129
*
3130-
* @param string $column
3130+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
31313131
* @return mixed
31323132
*/
31333133
public function sum($column)
@@ -3140,7 +3140,7 @@ public function sum($column)
31403140
/**
31413141
* Retrieve the average of the values of a given column.
31423142
*
3143-
* @param string $column
3143+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
31443144
* @return mixed
31453145
*/
31463146
public function avg($column)
@@ -3151,7 +3151,7 @@ public function avg($column)
31513151
/**
31523152
* Alias for the "avg" method.
31533153
*
3154-
* @param string $column
3154+
* @param string|\Illuminate\Contracts\Database\Query\Expression $column
31553155
* @return mixed
31563156
*/
31573157
public function average($column)

0 commit comments

Comments
 (0)