Skip to content

Commit bd9b5e5

Browse files
authored
Revert Bit operators (#40791)
1 parent c239161 commit bd9b5e5

File tree

5 files changed

+0
-109
lines changed

5 files changed

+0
-109
lines changed

src/Illuminate/Database/Query/Builder.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,6 @@ class Builder
203203
'not similar to', 'not ilike', '~~*', '!~~*',
204204
];
205205

206-
/**
207-
* All of the available bit operators.
208-
*
209-
* @var string[]
210-
*/
211-
public $bitOperators = [
212-
'&', '|', '^', '<<', '>>', '&~',
213-
];
214-
215206
/**
216207
* Whether to use write pdo for the select.
217208
*
@@ -763,10 +754,6 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
763754
}
764755
}
765756

766-
if ($this->isBitOperator($operator)) {
767-
$type = 'Bit';
768-
}
769-
770757
// Now that we are working with just a simple query we can put the elements
771758
// in our array and add the query binding to our array of bindings that
772759
// will be bound to each SQL statements when it is finally executed.
@@ -850,18 +837,6 @@ protected function invalidOperator($operator)
850837
! in_array(strtolower($operator), $this->grammar->getOperators(), true);
851838
}
852839

853-
/**
854-
* Determine if the operator is a bit operator.
855-
*
856-
* @param string $operator
857-
* @return bool
858-
*/
859-
protected function isBitOperator($operator)
860-
{
861-
return in_array(strtolower($operator), $this->bitOperators, true) ||
862-
in_array(strtolower($operator), $this->grammar->getBitOperators(), true);
863-
}
864-
865840
/**
866841
* Add an "or where" clause to the query.
867842
*
@@ -1940,10 +1915,6 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
19401915
[$value, $operator] = [$operator, '='];
19411916
}
19421917

1943-
if ($this->isBitOperator($operator)) {
1944-
$type = 'bit';
1945-
}
1946-
19471918
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');
19481919

19491920
if (! $value instanceof Expression) {

src/Illuminate/Database/Query/Grammars/Grammar.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ class Grammar extends BaseGrammar
1818
*/
1919
protected $operators = [];
2020

21-
/**
22-
* The grammar specific bit operators.
23-
*
24-
* @var array
25-
*/
26-
protected $bitOperators = [];
27-
2821
/**
2922
* The components that make up a select clause.
3023
*
@@ -262,22 +255,6 @@ protected function whereBasic(Builder $query, $where)
262255
return $this->wrap($where['column']).' '.$operator.' '.$value;
263256
}
264257

265-
/**
266-
* Compile a bit operator where clause.
267-
*
268-
* @param \Illuminate\Database\Query\Builder $query
269-
* @param array $where
270-
* @return string
271-
*/
272-
protected function whereBit(Builder $query, $where)
273-
{
274-
$value = $this->parameter($where['value']);
275-
276-
$operator = str_replace('?', '??', $where['operator']);
277-
278-
return '('.$this->wrap($where['column']).' '.$operator.' '.$value.') != 0';
279-
}
280-
281258
/**
282259
* Compile a "where in" clause.
283260
*
@@ -708,8 +685,6 @@ protected function compileHaving(array $having)
708685
return $having['boolean'].' '.$having['sql'];
709686
} elseif ($having['type'] === 'between') {
710687
return $this->compileHavingBetween($having);
711-
} elseif ($having['type'] === 'bit') {
712-
return $this->compileHavingBit($having);
713688
}
714689

715690
return $this->compileBasicHaving($having);
@@ -749,21 +724,6 @@ protected function compileHavingBetween($having)
749724
return $having['boolean'].' '.$column.' '.$between.' '.$min.' and '.$max;
750725
}
751726

752-
/**
753-
* Compile a having clause involving a bit operator.
754-
*
755-
* @param array $having
756-
* @return string
757-
*/
758-
protected function compileHavingBit($having)
759-
{
760-
$column = $this->wrap($having['column']);
761-
762-
$parameter = $this->parameter($having['value']);
763-
764-
return $having['boolean'].' ('.$column.' '.$having['operator'].' '.$parameter.') != 0';
765-
}
766-
767727
/**
768728
* Compile the "order by" portions of the query.
769729
*
@@ -1339,14 +1299,4 @@ public function getOperators()
13391299
{
13401300
return $this->operators;
13411301
}
1342-
1343-
/**
1344-
* Get the grammar specific bit operators.
1345-
*
1346-
* @return array
1347-
*/
1348-
public function getBitOperators()
1349-
{
1350-
return $this->bitOperators;
1351-
}
13521302
}

src/Illuminate/Database/Query/Grammars/PostgresGrammar.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ class PostgresGrammar extends Grammar
2121
'is distinct from', 'is not distinct from',
2222
];
2323

24-
/**
25-
* The grammar specific bit operators.
26-
*
27-
* @var array
28-
*/
29-
protected $bitOperators = [
30-
'~', '&', '|', '#', '<<', '>>', '<<=', '>>=',
31-
];
32-
3324
/**
3425
* {@inheritdoc}
3526
*

tests/Database/DatabaseEloquentModelTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,6 @@ protected function addMockConnection($model)
21532153
$model->setConnectionResolver($resolver = m::mock(ConnectionResolverInterface::class));
21542154
$resolver->shouldReceive('connection')->andReturn($connection = m::mock(Connection::class));
21552155
$connection->shouldReceive('getQueryGrammar')->andReturn($grammar = m::mock(Grammar::class));
2156-
$grammar->shouldReceive('getBitOperators')->andReturn([]);
21572156
$connection->shouldReceive('getPostProcessor')->andReturn($processor = m::mock(Processor::class));
21582157
$connection->shouldReceive('query')->andReturnUsing(function () use ($connection, $grammar, $processor) {
21592158
return new BaseBuilder($connection, $grammar, $processor);
@@ -2441,7 +2440,6 @@ public function getConnection()
24412440
{
24422441
$mock = m::mock(Connection::class);
24432442
$mock->shouldReceive('getQueryGrammar')->andReturn($grammar = m::mock(Grammar::class));
2444-
$grammar->shouldReceive('getBitOperators')->andReturn([]);
24452443
$mock->shouldReceive('getPostProcessor')->andReturn($processor = m::mock(Processor::class));
24462444
$mock->shouldReceive('getName')->andReturn('name');
24472445
$mock->shouldReceive('query')->andReturnUsing(function () use ($mock, $grammar, $processor) {

tests/Database/DatabaseQueryBuilderTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,25 +3209,6 @@ public function testMySqlSoundsLikeOperator()
32093209
$this->assertEquals(['John Doe'], $builder->getBindings());
32103210
}
32113211

3212-
public function testBitOperators()
3213-
{
3214-
$builder = $this->getBuilder();
3215-
$builder->select('*')->from('users')->where('bar', '&', 1);
3216-
$this->assertSame('select * from "users" where ("bar" & ?) != 0', $builder->toSql());
3217-
3218-
$builder = $this->getPostgresBuilder();
3219-
$builder->select('*')->from('users')->where('bar', '#', 1);
3220-
$this->assertSame('select * from "users" where ("bar" # ?) != 0', $builder->toSql());
3221-
3222-
$builder = $this->getBuilder();
3223-
$builder->select('*')->from('users')->having('bar', '&', 1);
3224-
$this->assertSame('select * from "users" having ("bar" & ?) != 0', $builder->toSql());
3225-
3226-
$builder = $this->getPostgresBuilder();
3227-
$builder->select('*')->from('users')->having('bar', '#', 1);
3228-
$this->assertSame('select * from "users" having ("bar" # ?) != 0', $builder->toSql());
3229-
}
3230-
32313212
public function testMergeWheresCanMergeWheresAndBindings()
32323213
{
32333214
$builder = $this->getBuilder();

0 commit comments

Comments
 (0)