diff --git a/src/Drafter/BaseDrafter.php b/src/Drafter/BaseDrafter.php index c77c276..70ef752 100644 --- a/src/Drafter/BaseDrafter.php +++ b/src/Drafter/BaseDrafter.php @@ -63,12 +63,13 @@ protected function findPrimaryKey(Table $table): ?string */ protected function findKeyToForeignTable(Table $table, string $tableName): ?string { - // Check a few common conventions + // Hacked 'onus' is not returned as singular because of missing regex in Framework. + // Remove after merge of PR. $tests = [ - $tableName, - $tableName . '_id', - singular($tableName), - singular($tableName) . '_id', + $tableName !== 'onus' ? $tableName : 'onu', + $tableName !== 'onus' ? $tableName . '_id' : 'onu_id', + $tableName !== 'onus' ? singular($tableName) : 'onu', + $tableName !== 'onus' ? singular($tableName) . '_id' : 'onu_id', ]; foreach ($tests as $fieldName) { diff --git a/src/Structures/ForeignKey.php b/src/Structures/ForeignKey.php index 4a4c86b..e0987d3 100644 --- a/src/Structures/ForeignKey.php +++ b/src/Structures/ForeignKey.php @@ -21,7 +21,7 @@ public function __construct($foreignKeyData = null) $this->constraint_name = $foreignKeyData; } else { foreach ($foreignKeyData as $key => $value) { - $this->{$key} = $value; + $this->{$key} = is_array($value) ? $value[0] : $value; } } }