-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6.x] Fix plucking column name containing a space
- Loading branch information
1 parent
fc844ce
commit 62d6d99
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,13 @@ protected function createSchema() | |
$table->timestamps(); | ||
}); | ||
|
||
$this->schema('default')->create('users_with_space_in_colum_name', function ($table) { | ||
$table->increments('id'); | ||
$table->string('name')->nullable(); | ||
$table->string('email address'); | ||
$table->timestamps(); | ||
}); | ||
|
||
foreach (['default', 'second_connection'] as $connection) { | ||
$this->schema($connection)->create('users', function ($table) { | ||
$table->increments('id'); | ||
|
@@ -443,6 +450,18 @@ public function testPluckWithJoin() | |
$this->assertEquals(['[email protected]' => 'First post', '[email protected]' => 'Second post'], $query->pluck('posts.name', 'users.email as user_email')->all()); | ||
} | ||
|
||
public function testPluckWithColumnNameContainingASpace() | ||
{ | ||
EloquentTestUserWithSpaceInColumnName::create(['id' => 1, 'email address' => '[email protected]']); | ||
EloquentTestUserWithSpaceInColumnName::create(['id' => 2, 'email address' => '[email protected]']); | ||
|
||
$simple = EloquentTestUserWithSpaceInColumnName::oldest('id')->pluck('users_with_space_in_colum_name.email address')->all(); | ||
$keyed = EloquentTestUserWithSpaceInColumnName::oldest('id')->pluck('email address', 'id')->all(); | ||
|
||
$this->assertEquals(['[email protected]', '[email protected]'], $simple); | ||
$this->assertEquals([1 => '[email protected]', 2 => '[email protected]'], $keyed); | ||
} | ||
|
||
public function testFindOrFail() | ||
{ | ||
EloquentTestUser::create(['id' => 1, 'email' => '[email protected]']); | ||
|
@@ -1673,6 +1692,11 @@ public function friends() | |
} | ||
} | ||
|
||
class EloquentTestUserWithSpaceInColumnName extends EloquentTestUser | ||
{ | ||
protected $table = 'users_with_space_in_colum_name'; | ||
} | ||
|
||
class EloquentTestNonIncrementing extends Eloquent | ||
{ | ||
protected $table = 'non_incrementing_users'; | ||
|