Skip to content

Commit

Permalink
Make codegen slightly more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 9, 2023
1 parent 3d84003 commit e27e311
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/BuildSchemaCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ public static function getRenderedHackTableSchema(
$file_contents .= $indentation."\t\t\t\t'{$field->name}',\n";
$file_contents .= $indentation."\t\t\t\tDataType::{$field->type},\n";
$file_contents .= $indentation."\t\t\t\t{$field->length},\n";
$file_contents .= $indentation."\t\t\t\t" . ($field->null ? 'true' : 'false') . ",\n";
$file_contents .= $indentation."\t\t\t\t" . \var_export($field->null, true) . ",\n";
$file_contents .= $indentation."\t\t\t\t'{$field->hack_type}',\n";
if ($field->unsigned is nonnull || $field->default is nonnull) {
if ($field->unsigned is nonnull) {
$file_contents .= $indentation."\t\t\t\t" . ($field->unsigned ? 'true' : 'false') . ",\n";
$file_contents .= $indentation."\t\t\t\t" . \var_export($field->unsigned, true) . ",\n";
} else {
$file_contents .= $indentation."\t\t\t\tnull,\n";
}
if ($field->default is nonnull) {
$file_contents .= $indentation."\t\t\t\t'{$field->default}',\n";
$file_contents .= $indentation."\t\t\t\t\"{$field->default}\",\n";
}
}
$file_contents .= $indentation."\t\t\t),\n";
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/expected_schema.codegen
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function get_my_table_schemas(): dict<string, dict<string, TableSchema>> {
false,
'int',
true,
'0',
"0",
),
new Column(
'name',
Expand Down

0 comments on commit e27e311

Please sign in to comment.