Skip to content

Commit

Permalink
Merge branch '0.1' into 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Oct 13, 2021
2 parents 77804c1 + 64f7092 commit d7381ce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib/Importer/SchemaImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ private function importSchemaTable(
): void {
$table = $schema->createTable($tableName);

if (!empty($defaultTableOptions)) {
foreach ($defaultTableOptions as $name => $value) {
$table->addOption($name, $value);
}
}

if (isset($tableConfiguration['id'])) {
$this->addSchemaTableColumns($table, $tableConfiguration['id']);
$table->setPrimaryKey(array_keys($tableConfiguration['id']));
Expand Down Expand Up @@ -126,6 +120,14 @@ private function addSchemaTableColumns(Table $table, array $columnList): void
$columnConfiguration['options']['length'] = $columnConfiguration['length'];
}

if (isset($columnConfiguration['scale'])) {
$columnConfiguration['options']['scale'] = $columnConfiguration['scale'];
}

if (isset($columnConfiguration['precision'])) {
$columnConfiguration['options']['precision'] = $columnConfiguration['precision'];
}

$column = $table->addColumn(
$columnName,
$columnConfiguration['type'],
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/Importer/SchemaImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ public function providerForTestImportFromFile(): array
]
),
],
7 => [
'07-numeric-options.yaml',
new Schema(
[
new Table(
'my_table',
[
(new Column(
'data',
Type::getType('decimal'))
)->setPrecision(19)->setScale(4),
]
),
]
),
],
];

return $data;
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/Importer/_fixtures/07-numeric-options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tables:
my_table:
fields:
data: { type: decimal, precision: 19, scale: 4 }

0 comments on commit d7381ce

Please sign in to comment.