Make sure default values in schema columns are always non-empty (especially booleans).
This commit is contained in:
parent
25b8bd889b
commit
61364c553d
|
@ -96,4 +96,19 @@ protected function type(Fluent $column)
|
|||
return $this->{'type_'.$column->type}($column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a value so that it can be used in SQL DEFAULT clauses.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function default_value($value)
|
||||
{
|
||||
if (is_bool($value))
|
||||
{
|
||||
return intval($value);
|
||||
}
|
||||
|
||||
return strval($value);
|
||||
}
|
||||
|
||||
}
|
|
@ -128,7 +128,7 @@ protected function defaults(Table $table, Fluent $column)
|
|||
{
|
||||
if ( ! is_null($column->default))
|
||||
{
|
||||
return " DEFAULT '".$column->default."'";
|
||||
return " DEFAULT '".$this->default_value($column->default)."'";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ protected function defaults(Table $table, Fluent $column)
|
|||
{
|
||||
if ( ! is_null($column->default))
|
||||
{
|
||||
return " DEFAULT '".$column->default."'";
|
||||
return " DEFAULT '".$this->default_value($column->default)."'";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ protected function defaults(Table $table, Fluent $column)
|
|||
{
|
||||
if ( ! is_null($column->default))
|
||||
{
|
||||
return ' DEFAULT '.$this->wrap($column->default);
|
||||
return ' DEFAULT '.$this->wrap($this->default_value($column->default));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ protected function defaults(Table $table, Fluent $column)
|
|||
{
|
||||
if ( ! is_null($column->default))
|
||||
{
|
||||
return " DEFAULT '".$column->default."'";
|
||||
return " DEFAULT '".$this->default_value($column->default)."'";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue