Commit 61364c55 by Franz Liedke

Make sure default values in schema columns are always non-empty (especially booleans).

parent 25b8bd88
...@@ -96,4 +96,19 @@ abstract class Grammar extends \Laravel\Database\Grammar { ...@@ -96,4 +96,19 @@ abstract class Grammar extends \Laravel\Database\Grammar {
return $this->{'type_'.$column->type}($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);
}
} }
\ No newline at end of file
...@@ -128,7 +128,7 @@ class MySQL extends Grammar { ...@@ -128,7 +128,7 @@ class MySQL extends Grammar {
{ {
if ( ! is_null($column->default)) if ( ! is_null($column->default))
{ {
return " DEFAULT '".$column->default."'"; return " DEFAULT '".$this->default_value($column->default)."'";
} }
} }
......
...@@ -101,7 +101,7 @@ class Postgres extends Grammar { ...@@ -101,7 +101,7 @@ class Postgres extends Grammar {
{ {
if ( ! is_null($column->default)) if ( ! is_null($column->default))
{ {
return " DEFAULT '".$column->default."'"; return " DEFAULT '".$this->default_value($column->default)."'";
} }
} }
......
...@@ -127,7 +127,7 @@ class SQLite extends Grammar { ...@@ -127,7 +127,7 @@ class SQLite extends Grammar {
{ {
if ( ! is_null($column->default)) if ( ! is_null($column->default))
{ {
return ' DEFAULT '.$this->wrap($column->default); return ' DEFAULT '.$this->wrap($this->default_value($column->default));
} }
} }
......
...@@ -108,7 +108,7 @@ class SQLServer extends Grammar { ...@@ -108,7 +108,7 @@ class SQLServer extends Grammar {
{ {
if ( ! is_null($column->default)) if ( ! is_null($column->default))
{ {
return " DEFAULT '".$column->default."'"; return " DEFAULT '".$this->default_value($column->default)."'";
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment