Skip to content

Commit

Permalink
create implicit Join ID field with "bigint" type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 29, 2024
1 parent 9606f6d commit c5b7b5a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Model/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function createFakeForeignModel(): Model
}
}
if ($fakeModel->idField !== $this->foreignField) {
$fakeModel->addField($this->foreignField, ['type' => 'integer']);
$fakeModel->addField($this->foreignField, ['type' => 'bigint']);
}

return $fakeModel;
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence/Sql/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ protected function init(): void
// TODO this mutates the owner model/joins!
if (!$this->reverse && !$this->getOwner()->hasField($this->masterField)) {
$owner = $this->hasJoin() ? $this->getJoin() : $this->getOwner();
$field = $owner->addField($this->masterField, ['type' => 'integer', 'system' => true, 'readOnly' => true]);
$field = $owner->addField($this->masterField, ['type' => 'bigint', 'system' => true, 'readOnly' => true]);
$this->masterField = $field->shortName; // TODO this mutates the join!
} elseif ($this->reverse && !$this->getOwner()->hasField($this->foreignField) && $this->hasJoin()) {
$owner = $this->getJoin();
$field = $owner->addField($this->foreignField, ['type' => 'integer', 'system' => true, 'readOnly' => true, 'actual' => $this->masterField]);
$field = $owner->addField($this->foreignField, ['type' => 'bigint', 'system' => true, 'readOnly' => true, 'actual' => $this->masterField]);
$this->foreignField = $field->shortName; // TODO this mutates the join!
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/JoinArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testJoinSaving1(): void
$db = new Persistence\Array_(['user' => [], 'contact' => []]);
$user = new Model($db, ['table' => 'user']);
$user->addField('name');
$user->addField('contact_id', ['type' => 'integer']);
$user->addField('contact_id', ['type' => 'bigint']);
$j = $user->join('contact');
$j->addField('contact_phone');

Expand Down

0 comments on commit c5b7b5a

Please sign in to comment.