Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
cd9a745c
Commit
cd9a745c
authored
Jul 19, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #972 from franzliedke/patch-28
[Schema] Allow boolean default values
parents
527e291f
61364c55
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
4 deletions
+20
-4
laravel/database/schema/grammars/grammar.php
+16
-0
laravel/database/schema/grammars/mysql.php
+1
-1
laravel/database/schema/grammars/postgres.php
+1
-1
laravel/database/schema/grammars/sqlite.php
+1
-1
laravel/database/schema/grammars/sqlserver.php
+1
-1
No files found.
laravel/database/schema/grammars/grammar.php
View file @
cd9a745c
...
...
@@ -96,4 +96,19 @@ abstract class Grammar extends \Laravel\Database\Grammar {
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
laravel/database/schema/grammars/mysql.php
View file @
cd9a745c
...
...
@@ -128,7 +128,7 @@ class MySQL extends Grammar {
{
if
(
!
is_null
(
$column
->
default
))
{
return
" DEFAULT '"
.
$
column
->
default
.
"'"
;
return
" DEFAULT '"
.
$
this
->
default_value
(
$column
->
default
)
.
"'"
;
}
}
...
...
laravel/database/schema/grammars/postgres.php
View file @
cd9a745c
...
...
@@ -101,7 +101,7 @@ class Postgres extends Grammar {
{
if
(
!
is_null
(
$column
->
default
))
{
return
" DEFAULT '"
.
$
column
->
default
.
"'"
;
return
" DEFAULT '"
.
$
this
->
default_value
(
$column
->
default
)
.
"'"
;
}
}
...
...
laravel/database/schema/grammars/sqlite.php
View file @
cd9a745c
...
...
@@ -127,7 +127,7 @@ class SQLite extends Grammar {
{
if
(
!
is_null
(
$column
->
default
))
{
return
' DEFAULT '
.
$this
->
wrap
(
$
column
->
default
);
return
' DEFAULT '
.
$this
->
wrap
(
$
this
->
default_value
(
$column
->
default
)
);
}
}
...
...
laravel/database/schema/grammars/sqlserver.php
View file @
cd9a745c
...
...
@@ -108,7 +108,7 @@ class SQLServer extends Grammar {
{
if
(
!
is_null
(
$column
->
default
))
{
return
" DEFAULT '"
.
$
column
->
default
.
"'"
;
return
" DEFAULT '"
.
$
this
->
default_value
(
$column
->
default
)
.
"'"
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment