Skip to content

Commit

Permalink
SQLServerGrammar: added collation support
Browse files Browse the repository at this point in the history
You can define collation in table creation:

Schema::create('table_name', function (Blueprint $table) {
    $table->string('field_name')->collation('Latin1_General_CS_AS');
});

This is same implementation as MySQL grammar
  • Loading branch information
dmoreno authored Nov 2, 2016
1 parent f18ae93 commit 8be6291
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SqlServerGrammar extends Grammar
*
* @var array
*/
protected $modifiers = ['Increment', 'Nullable', 'Default'];
protected $modifiers = ['Increment', 'Collate', 'Nullable', 'Default'];

/**
* The columns available as serials.
Expand Down Expand Up @@ -596,6 +596,20 @@ protected function modifyNullable(Blueprint $blueprint, Fluent $column)
return $column->nullable ? ' null' : ' not null';
}

/**
* Get the SQL for a collation column modifier.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $column
* @return string|null
*/
protected function modifyCollate(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->collation)) {
return ' collate '.$column->collation;
}
}

/**
* Get the SQL for a default column modifier.
*
Expand Down

0 comments on commit 8be6291

Please sign in to comment.