When adding multiple organisation relations to a contacts view, the is_primary field breaks the view because it doesn't use a table alias. it tries to do a lookup via ensure_table() but doesn't check the return value and doesn't actually use the alias is finds, if any...

I note the code in question has a @todo so clearly this is a known problem :-)

Comments

cafuego’s picture

Status: Active » Needs review
StatusFileSize
new1.79 KB

Attached patch adds a wrapper for $this->query->ensure_table() that checks the list of relation tables and returns the alias for the correct one.

I'm not sure if this is the right way to fix the problem, but it definitely works just fine for my view with three different contact-> relation -> org relationships.

cafuego’s picture

Issue summary: View changes
cafuego’s picture

StatusFileSize
new0 bytes

Oops, forgot to actually use the newly looked-up $org_table in the query.

cafuego’s picture

StatusFileSize
new1.88 KB

Srsly.

levelos’s picture

Status: Needs review » Fixed

  • levelos committed 7b4ce59 on 7.x-1.x authored by cafuego
    Issue #2325223 by cafuego: Table for is_primary not aliased in views
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.