Skip to content

Commit 4866ccf

Browse files
committed
:octocat: boolean field fix
1 parent a4c9098 commit 4866ccf

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/Dialects/Firebird.php

+3
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ public function fieldspec(string $name, string $type, $length = null, string $at
162162
case strtoupper($defaultValue) === 'NULL' && $isNull === true:
163163
$field[] = 'DEFAULT NULL';
164164
break;
165+
case $type === 'BOOLEAN':
166+
$field[] = 'DEFAULT '.(preg_match('/^1|T|TRUE|YES$/i', $defaultValue) ? '1' : '0');
167+
break;
165168
default:
166169
$field[] = 'DEFAULT \''.$defaultValue.'\'';
167170
}

src/Dialects/MSSQL.php

+3
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public function fieldspec(string $name, string $type, $length = null, string $at
121121

122122
// @todo
123123
switch(true){
124+
case $type === 'BOOLEAN':
125+
$field[] = 'DEFAULT '.(preg_match('/^1|T|TRUE|YES$/i', $defaultValue) ? '1' : '0');
126+
break;
124127
default:
125128
$field[] = 'DEFAULT \''.$defaultValue.'\'';
126129
}

src/Dialects/MySQL.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function fieldspec(string $name, string $type, $length = null, string $at
160160
$field[] = 'DEFAULT b\''.preg_replace('/[^01]/', '0', $defaultValue).'\'';
161161
break;
162162
case $type === 'BOOLEAN':
163-
$field[] = 'DEFAULT '.preg_match('/^1|T|TRUE|YES$/i', $defaultValue) ? 'TRUE' : 'FALSE';
163+
$field[] = 'DEFAULT '.(preg_match('/^1|T|TRUE|YES$/i', $defaultValue) ? 'TRUE' : 'FALSE');
164164
break;
165165
case $type === 'BINARY' || $type === 'VARBINARY':
166166
$field[] = 'DEFAULT 0x'.$defaultValue;

src/Dialects/Postgres.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function fieldspec(string $name, string $type, $length = null, string $at
178178
$field[] = 'DEFAULT b\''.preg_replace('/[^01]/', '0', $defaultValue).'\'';
179179
break;
180180
case $type === 'BOOLEAN':
181-
$field[] = 'DEFAULT '.preg_match('/^1|T|TRUE|YES$/i', $defaultValue) ? 'TRUE' : 'FALSE';
181+
$field[] = 'DEFAULT '.(preg_match('/^1|T|TRUE|YES$/i', $defaultValue) ? 'TRUE' : 'FALSE');
182182
break;
183183
case strtoupper($defaultValue) === 'NULL' && $isNull === true:
184184
$field[] = 'DEFAULT NULL';

0 commit comments

Comments
 (0)