Ticket #1272 (closed defect: fixed)

Opened 4 months ago

Last modified 3 months ago

Missing identifier quoting on many-to-many associations query build

Reported by: mm Owned by: romanb
Priority: blocker Milestone:
Component: Query/Hydration Version: 0.11.0
Keywords: quoting, query, ATTR_QUOTE_IDENTIFIER Cc:
Has Test: no Status: Pending Core Response
Has Patch: yes

Description

Same behavior like in ticket #1262, but this affect queries that use in their body refClass to use joins.

Problem found in Doctrine_Query line 1551 to 1565;

Actual:

                    $queryPart = $join . $assocTableName . ' ' . $assocAlias;

                    $queryPart .= ' ON ' . $localAlias
                                . '.'
                                . $localTable->getColumnName($localTable->getIdentifier()) // what about composite keys?
                                . ' = '
                                . $assocAlias . '.' . $relation->getLocal();

                    if ($relation->isEqual()) {
                        // equal nest relation needs additional condition
                        $queryPart .= ' OR ' . $localAlias
                                    . '.'
                                    . $table->getColumnName($table->getIdentifier())
                                    . ' = '
                                    . $assocAlias . '.' . $relation->getForeign();
                    }

Patch:

                    $queryPart = $join . $this->_conn->quoteIdentifier($assocTableName) . ' ' . $this->_conn->quoteIdentifier($assocAlias);

                    $queryPart .= ' ON '
                                . $this->_conn->quoteIdentifier($localAlias . '.'
                                . $localTable->getColumnName($localTable->getIdentifier())) // what about composite keys?
                                . ' = '
                                . $this->_conn->quoteIdentifier($assocAlias . '.' . $relation->getLocal());

                    if ($relation->isEqual()) {
                        // equal nest relation needs additional condition
                        $queryPart .= ' OR '
                                    . $this->_conn->quoteIdentifier($localAlias . '.'
                                    . $table->getColumnName($table->getIdentifier()))
                                    . ' = '
                                    . $this->_conn->quoteIdentifier($assocAlias . '.' . $relation->getForeign());
                    }

Attachments

Query.php (69.0 KB) - added by mm 4 months ago.
Patched file

Change History

Changed 4 months ago by mm

Patched file

Changed 4 months ago by guilhermeblanco

  • status changed from new to closed
  • resolution set to fixed

In r4708 fixed #1262 and fixed #1272.

Changed 3 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.