Cakephp: Improve association data fetching

Created on 22 Sep 2016  路  4Comments  路  Source: cakephp/cakephp

This is a ticket to track the many improvements we need to make on contain() and friends:

  • [ ] Allow alias overriding for associations. (refs #8448 and #5214) This is tricky, since folks would probably expect aliases in conditions to be automatically renamed. We could encourage using $table->aliasField() as a way to help us minimise the risk of using the wrong alias.
  • [ ] The association path should be followed strictly when building the matching graph. This graph should not be hijacked by other associations. (refs #8662)
  • [ ] More resilient joins nesting. I thought the logic around letting custom finders inject joins was sound, but it seems like it still has some rough edges (refs #8380)
  • [ ] There should be a way to specify what fields in the junction tables should be selected. (refs #6777)
ORM enhancement stale

Most helpful comment

Setting a temporary alias in matching/contain could be pretty useful.

All 4 comments

Change the alias dynamically would be really handy, creating another Association isn't the best idea. Any idea if/when this will be implemented?

An easy fix for setting alias on matching would be for the first param to support array and use the same format as leftJoin which where table can be ['alias' => 'tablename']

Disclaimer: I haven't looked into the matching code ;-)

Setting a temporary alias in matching/contain could be pretty useful.

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

Was this page helpful?
0 / 5 - 0 ratings