Skip to content

Commit b6064a6

Browse files
authored
fix(database): default strong comparison check (#858)
1 parent e332bbd commit b6064a6

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

src/Tempest/Database/src/QueryStatements/CharStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function compile(DatabaseDialect $dialect): string
2121
return sprintf(
2222
'`%s` CHAR %s %s',
2323
$this->name,
24-
$this->default ? "DEFAULT \"{$this->default}\"" : '',
24+
$this->default !== null ? "DEFAULT \"{$this->default}\"" : '',
2525
$this->nullable ? '' : 'NOT NULL',
2626
);
2727
}

src/Tempest/Database/src/QueryStatements/DateStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function compile(DatabaseDialect $dialect): string
2121
return sprintf(
2222
'`%s` DATE %s %s',
2323
$this->name,
24-
$this->default ? "DEFAULT \"{$this->default}\"" : '',
24+
$this->default !== null ? "DEFAULT \"{$this->default}\"" : '',
2525
$this->nullable ? '' : 'NOT NULL',
2626
);
2727
}

src/Tempest/Database/src/QueryStatements/DatetimeStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function compile(DatabaseDialect $dialect): string
2121
return sprintf(
2222
'`%s` DATETIME %s %s',
2323
$this->name,
24-
$this->default ? "DEFAULT \"{$this->default}\"" : '',
24+
$this->default !== null ? "DEFAULT \"{$this->default}\"" : '',
2525
$this->nullable ? '' : 'NOT NULL',
2626
);
2727
}

src/Tempest/Database/src/QueryStatements/FloatStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function compile(DatabaseDialect $dialect): string
2121
return sprintf(
2222
'`%s` FLOAT %s %s',
2323
$this->name,
24-
$this->default ? "DEFAULT {$this->default}" : '',
24+
$this->default !== null ? "DEFAULT {$this->default}" : '',
2525
$this->nullable ? '' : 'NOT NULL',
2626
);
2727
}

src/Tempest/Database/src/QueryStatements/IntegerStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function compile(DatabaseDialect $dialect): string
2323
'`%s` INTEGER %s %s %s',
2424
$this->name,
2525
$this->unsigned ? 'UNSIGNED' : '',
26-
$this->default ? "DEFAULT {$this->default}" : '',
26+
$this->default !== null ? "DEFAULT {$this->default}" : '',
2727
$this->nullable ? '' : 'NOT NULL',
2828
);
2929
}

src/Tempest/Database/src/QueryStatements/JsonStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public function compile(DatabaseDialect $dialect): string
3232
DatabaseDialect::SQLITE => sprintf(
3333
'`%s` TEXT %s %s',
3434
$this->name,
35-
$this->default ? "DEFAULT '{$this->default}'" : '',
35+
$this->default !== null ? "DEFAULT '{$this->default}'" : '',
3636
$this->nullable ? '' : 'NOT NULL',
3737
),
3838
DatabaseDialect::POSTGRESQL => sprintf(
3939
'`%s` JSONB %s %s',
4040
$this->name,
41-
$this->default ? "DEFAULT (\"{$this->default}\")" : '',
41+
$this->default !== null ? "DEFAULT (\"{$this->default}\")" : '',
4242
$this->nullable ? '' : 'NOT NULL',
4343
),
4444
};

src/Tempest/Database/src/QueryStatements/TextStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function compile(DatabaseDialect $dialect): string
2727
default => sprintf(
2828
'`%s` TEXT %s %s',
2929
$this->name,
30-
$this->default ? "DEFAULT \"{$this->default}\"" : '',
30+
$this->default !== null ? "DEFAULT \"{$this->default}\"" : '',
3131
$this->nullable ? '' : 'NOT NULL',
3232
),
3333
};

src/Tempest/Database/src/QueryStatements/VarcharStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function compile(DatabaseDialect $dialect): string
2323
'`%s` VARCHAR(%s) %s %s',
2424
$this->name,
2525
$this->size,
26-
$this->default ? "DEFAULT \"{$this->default}\"" : '',
26+
$this->default !== null ? "DEFAULT \"{$this->default}\"" : '',
2727
$this->nullable ? '' : 'NOT NULL',
2828
);
2929
}

0 commit comments

Comments
 (0)