From 577427a90589a4f35ef5c58c28998236f07769d2 Mon Sep 17 00:00:00 2001 From: edvordo Date: Thu, 18 Apr 2019 11:41:26 +0200 Subject: [PATCH] Fix issue #28251 --- src/Illuminate/Database/Query/Builder.php | 4 ++-- .../Database/EloquentBelongsToManyTest.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 1276c11a4dde..adafdf66cffa 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -619,11 +619,11 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' // If the operator is a literal string 'in' or 'not in', we will assume that // the developer wants to use the "whereIn / whereNotIn" methods for this // operation and proxy the query through those methods from this point. - if ($operator == 'in') { + if ($operator === 'in') { return $this->whereIn($column, $value, $boolean); } - if ($operator == 'not in') { + if ($operator === 'not in') { return $this->whereNotIn($column, $value, $boolean); } diff --git a/tests/Integration/Database/EloquentBelongsToManyTest.php b/tests/Integration/Database/EloquentBelongsToManyTest.php index 88e3f138df5d..216c9e61b47c 100644 --- a/tests/Integration/Database/EloquentBelongsToManyTest.php +++ b/tests/Integration/Database/EloquentBelongsToManyTest.php @@ -604,6 +604,24 @@ public function test_global_scope_columns() $this->assertEquals(['id' => 1], $tags[0]->getAttributes()); } + + public function test_where_pivot_with_boolean_column_query() + { + Schema::table('posts_tags', function (Blueprint $table) { + $table->boolean('primary')->default(false)->after('flag'); + }); + + $tag = Tag::create(['name' => Str::random()]); + $post = Post::create(['title' => Str::random()]); + + DB::table('posts_tags')->insert([ + ['post_id' => $post->id, 'tag_id' => $tag->id, 'primary' => true] + ]); + + $relationTag = $post->tags()->wherePivot('primary', true)->first(); + + $this->assertEquals($relationTag->getAttributes(), $tag->getAttributes()); + } } class Post extends Model