Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Drafter/BaseDrafter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Structures/ForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down