Skip to content

Unify common methods#914

Merged
mvorisek merged 19 commits intodevelopfrom
unify_methods
Nov 10, 2021
Merged

Unify common methods#914
mvorisek merged 19 commits intodevelopfrom
unify_methods

Conversation

@mvorisek
Copy link
Copy Markdown
Member

@mvorisek mvorisek commented Nov 9, 2021

No description provided.

@mvorisek mvorisek requested a review from DarkSide666 November 9, 2021 18:40
@mvorisek mvorisek marked this pull request as ready for review November 9, 2021 18:40
// handle foreign table containing a dot - that will be reverse join
if (strpos($this->foreign_table, '.') !== false) {
// split by LAST dot in foreign_table name
[$this->foreign_table, $this->foreign_field] = preg_split('~\.+(?=[^.]+$)~', $this->foreign_table);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI foreign_table table is used as an index when added to a Model, must be set prior init

@mvorisek mvorisek added the RTM label Nov 10, 2021
if (strpos($this->foreign_table, '.') !== false) {
// split by LAST dot in foreign_table name
[$this->foreign_table, $this->foreign_field] = preg_split('~\.+(?=[^.]+$)~', $this->foreign_table);
$this->reverse = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we still overwrite $reverse property while initializing join?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

return $this->add(Join::fromSeed($this->_default_seed_join, $defaults));
$join = Join::fromSeed($this->_default_seed_join, $defaults);

if ($this->hasElement($name = $join->getDesiredName())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we join same table multiple times?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only one Join can be added which can be retrived by getJoin, same as for fields and references (even if the setup methods are named hasOne/hasMany)

@mvorisek mvorisek merged commit f7805b6 into develop Nov 10, 2021
@mvorisek mvorisek deleted the unify_methods branch November 10, 2021 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants