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

Add support for joins #175

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

sorinstanila
Copy link

Do you think we need more to have support for joins?

@vlucas
Copy link
Collaborator

vlucas commented Jun 9, 2016

I am not opposed to supporting joins, but I think doing is this way would be problematic for a number of reasons:

  • Spot uses custom syntax for WHERE conditions that is simpler than what DBAL wants. Any official JOIN support would have to use the known Spot syntax and translate it to the JOIN.
  • Fields in Spot can have aliases that need to be accounted for in JOIN conditions and columns
  • It probably should be possible to JOIN on a Spot Entity class name in addition to a raw table name
  • ... and many other concerns like that.

The primary reason Spot doesn't support them right now is that in general, I feel like if you are building complex queries, an ORM is not the best tool for the job, and will most likely result in an unoptimized and inefficient query. This Tweet is a prime example of what I am talking about here (happened TODAY, in fact.) https://twitter.com/naderman/status/740901123666644992

@sorinstanila
Copy link
Author

I believe that this library has a lot of potential and missing the support for join, is one of the key feature missing( as discussed in other pull requests/issues).
Yes, of course, we can find bad example for anything related to database loading, but if do not try to improve and learn from, it would not help :)
I will look on the things you mentioned and update the requests.
Any other feedback related to the implementation is welcomed and appreciated :)

@vlucas
Copy link
Collaborator

vlucas commented Jun 10, 2016

I agree that a good ORM should support joins, and would like to see them in Spot as an option for those who think differently than I do. I will help you work through it and support you all I can. I am looking forward to seeing what you come up with. 👍

this is reducing the complexity of the implementation and we can use the data already stored in Locator
@sorinstanila sorinstanila force-pushed the master branch 2 times, most recently from 9ddd785 to 74e9235 Compare June 13, 2016 15:10
@sorinstanila
Copy link
Author

I am also want to add eager loading of entities/mappers which are selected with the join. Right now is only populated the mapper which the join is created.
It still need to add some tests.

@vlucas
Copy link
Collaborator

vlucas commented Jun 13, 2016

Don't worry about the eager loading of relations for now - that is enough work for a separate PR after JOIN support is in (if it is even needed at all).

@mdular
Copy link
Contributor

mdular commented Jun 13, 2016

+1! :)

@sorinstanila
Copy link
Author

sorinstanila commented Jul 6, 2016

Sorry all for the long time awaiting this.
I broke my arm and I am still in recovery period. In 3 weeks I hope to get back :)

Sorin Valer Stanila added 2 commits July 27, 2016 14:35
added support for custom conditions as array
added missing code after merge from upstream
@luklub
Copy link

luklub commented Jul 29, 2016

+1
The lack of this feature is very noticeable.

@@ -17,6 +17,10 @@ class RegExp
*/
public function __invoke(QueryBuilder $builder, $column, $value)
{
if ($value instanceof \Closure) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be done at a higher level since all these are the same? i.e. do this before passing in the $value to the type classes.

$this->assertInstanceOf('\Spot\Entity\Manager', $manager);
$this->assertInstanceOf('\Spot\Entity\Manager', $managerCurrent);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any tests for the actual JOIN methods. Those need to be added to merge a feature that adds support for JOINs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants