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

[RFC] [3.3] Add support for associations in custom datasource #9002

Closed

Conversation

Marlinc
Copy link
Contributor

@Marlinc Marlinc commented Jun 17, 2016

These changes make it possible to use associations in custom datasources. It also moves some logic that is not very database ORM specific to the datasource component.

This is still a work in progress and comments are appreciated!

@@ -15,6 +15,7 @@
namespace Cake\ORM;

use ArrayIterator;
use Cake\Datasource\AssociationsNormalizerTrait;
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this leave us with a lot of duplicated code between ORM and Datasour e packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved AssociationsNormalizerTrait to the datasource package because its not very specific to the ORM.

Copy link
Member

Choose a reason for hiding this comment

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

I was trying to comment on the AssociationCollection as a whole. The ORM version is still there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I didn't see that. This has been resolved 👍

@lorenzo
Copy link
Member

lorenzo commented Jun 18, 2016

Is thee an alternative implementation of associations already available? I fear that we may be abstracting something without thinking if this is the right abstraction

@Marlinc
Copy link
Contributor Author

Marlinc commented Jun 19, 2016

I'm currently working on one for the Webservices plugin. I opened the PR so that the interface could be discussed 😄

@Marlinc Marlinc changed the title [WIP] [3.3] Add support for associations in custom datasource [RFC] [3.3] Add support for associations in custom datasource Jun 19, 2016
* required joins and decorating the results so that those associations can be
* part of the result set.
*/
interface EagerLoaderInterface
Copy link
Member

Choose a reason for hiding this comment

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

A good start would be not having this as an interface. This class is pretty much knowledgable of how joins work in SQL.

@lorenzo
Copy link
Member

lorenzo commented Jun 19, 2016

I think most of it makes sense, except for the functions I pointed out

@markstory
Copy link
Member

Closing as this can't be merged. If you have time @Marlinc to get this into a mergable state, we can discuss it further.

@markstory markstory closed this Jul 28, 2016
@lorenzo lorenzo reopened this Aug 8, 2016
public function add($alias, AssociationInterface $association)
{
list(, $alias) = pluginSplit($alias);
return $this->_items[strtolower($alias)] = $association;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing blank line before return statement


$out = array_filter($this->_items, function ($assoc) use ($class) {
list(, $name) = namespaceSplit(get_class($assoc));

return in_array(strtolower($name), $class, true);
return in_array($name, $class, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing blank line before return statement

* @param string $name The Association name.
* @param array $config The list of properties to set.
*/
public function __construct($name, array $config = [])
Copy link
Member

Choose a reason for hiding this comment

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

Codecov says there's no unit test coverage for this class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I'll look at this!

@markstory markstory modified the milestones: 3.3.0, 3.4.0 Aug 13, 2016
@josegonzalez
Copy link
Member

This needs another rebase :(

@dereuromark
Copy link
Member

Is this BC if you move classes without class_aliasing them?

src/ORM/AssociationCollection.php → src/Datasource/AssociationCollection.php

etc

@markstory
Copy link
Member

Closing as this can't be merged anymore. If it can be rebased we can discuss it further.

@ceeram
Copy link
Contributor

ceeram commented Jan 3, 2017

This is gonna be picked up again, im reopening this PR. Reopening before rebasing is needed since there is a bug in github. See: isaacs/github#361

@ceeram ceeram reopened this Jan 3, 2017
@ceeram
Copy link
Contributor

ceeram commented Jan 10, 2017

ping @Marlinc

@Marlinc Marlinc force-pushed the datasource-associations branch 2 times, most recently from c378b67 to 68a273c Compare January 10, 2017 13:32
@ceeram
Copy link
Contributor

ceeram commented Jan 10, 2017

Closing again for the time being, rebase has been done, can be reopened later when @Marlinc pushes more changes to further discuss

@ceeram ceeram closed this Jan 10, 2017
@ceeram
Copy link
Contributor

ceeram commented Jan 19, 2017

reopening again as requested by @Marlinc

@markstory markstory modified the milestones: 3.4.0, 3.5.0 Feb 13, 2017
@markstory
Copy link
Member

Closing until this can be put into a state where it can be merged.

@markstory markstory closed this Apr 16, 2017
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.

None yet

9 participants