You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
... A clear and concise description of what the bug is. A good bug report shouldn't leave others needing to chase you up for more information.
First issue:
I have table cards, with columns id, user_guid, number
I have table users, with columns id, guid
I have a foreign key from cards.user_guid to users.guid
I want to use $cardActiveRow->user, but it tries to use its foreign key instead of correctly using foreign key. I can use $cardActiveRow->ref("user", "user_guid"), but I'd rather let it get determined by the foreign key.
So I solved it temorarily by changing primary key in users table to users.guid.
Second issue:
This problem is solved now, but not when I use related()
Argument 3 passed to Nette\Database\Table\Selection::getReferencingTable() must be of the type integer or null, string given, called in ..../vendor/nette/database/src/Database/Table/ActiveRow.php on line 141 `
The function signature is
public function getReferencingTable(string $table, string $column = null, int $active = null):
which prevents primary key to be anything else than int, while primary key can be either string, int or array. That would probably lead to another problem, function related calls $groupedSelection = $this->table->getReferencingTable($key, $throughColumn, $this[$this->table->getPrimary()]);
where $this->table->getPrimary() can return int, array or string. I guess there would be problem with passing an array as an array index.
The primary key being int was fixed by removing typehint from Selection.php function getReferencingTable in the third argument $active and also GroupedSelection.php function setActive.
I am not opening pull request because I am not totally sure I am correct in all these statements and would like a followup.
The text was updated successfully, but these errors were encountered:
genesiscz
changed the title
Primary key as a string is not working because typehints
Primary key incorrectly used instead of foreign keys, string as a foreign key is not permitted because of typehints
Aug 14, 2019
Version: 3.0.2
Bug Description
... A clear and concise description of what the bug is. A good bug report shouldn't leave others needing to chase you up for more information.
First issue:
I have table cards, with columns id, user_guid, number
I have table users, with columns id, guid
I have a foreign key from cards.user_guid to users.guid
I want to use
$cardActiveRow->user
, but it tries to use its foreign key instead of correctly using foreign key. I can use$cardActiveRow->ref("user", "user_guid")
, but I'd rather let it get determined by the foreign key.So I solved it temorarily by changing primary key in users table to users.guid.
Second issue:
This problem is solved now, but not when I use related()
I get this error:
`TypeError
Argument 3 passed to Nette\Database\Table\Selection::getReferencingTable() must be of the type integer or null, string given, called in ..../vendor/nette/database/src/Database/Table/ActiveRow.php on line 141 `
The function signature is
public function getReferencingTable(string $table, string $column = null, int $active = null):
which prevents primary key to be anything else than int, while primary key can be either string, int or array. That would probably lead to another problem, function
related
calls$groupedSelection = $this->table->getReferencingTable($key, $throughColumn, $this[$this->table->getPrimary()]);
where
$this->table->getPrimary()
can return int, array or string. I guess there would be problem with passing an array as an array index.The primary key being int was fixed by removing typehint from
Selection.php
functiongetReferencingTable
in the third argument$active
and alsoGroupedSelection.php
functionsetActive
.I am not opening pull request because I am not totally sure I am correct in all these statements and would like a followup.
The text was updated successfully, but these errors were encountered: