Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify common methods #914

Merged
merged 19 commits into from
Nov 10, 2021
Merged

Unify common methods #914

merged 19 commits into from
Nov 10, 2021

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Nov 9, 2021

No description provided.

@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
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
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
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
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants