/** * @param ModelJoinBuilder $builder * @param $modelAttributeToDataProviderAdapter * @param null | string $onTableAliasName * @throws NotSupportedException if the display attribute is made via select like SUM(integer) but the * adapter being used is not a summation adapter */ protected function resolveDisplayAttributeForProcessingAllJoins(ModelJoinBuilder $builder, $modelAttributeToDataProviderAdapter, $onTableAliasName = null) { assert('$modelAttributeToDataProviderAdapter instanceof RedBeanModelAttributeToDataProviderAdapter'); assert('is_string($onTableAliasName) || $onTableAliasName == null'); $tableAliasName = $builder->resolveJoins($onTableAliasName, ModelDataProviderUtil::resolveCanUseFromJoins($onTableAliasName)); if ($this->isDisplayAttributeMadeViaSelect()) { if (!$this->modelToReportAdapter instanceof ModelRelationsAndAttributesToSummableReportAdapter) { throw new NotSupportedException(); } $this->modelToReportAdapter->resolveDisplayAttributeTypeAndAddSelectClause($this->selectQueryAdapter, $this->componentForm->getResolvedAttribute(), $tableAliasName, $this->resolveColumnName($modelAttributeToDataProviderAdapter), $this->componentForm->columnAliasName, $this->getAttributeClauseQueryStringExtraPart($tableAliasName)); } else { $tableAliasName = $this->resolvedTableAliasName($modelAttributeToDataProviderAdapter, $builder); $this->selectQueryAdapter->resolveIdClause($this->resolvedModelClassName($modelAttributeToDataProviderAdapter), $tableAliasName); $this->componentForm->setModelAliasUsingTableAliasName($tableAliasName); } }
public function testResolveIdClause() { $quote = DatabaseCompatibilityUtil::getQuote(); $adapter = new RedBeanModelSelectQueryAdapter(); $this->assertEquals(0, $adapter->getClausesCount()); $adapter->resolveIdClause('xModel', 'yTableAlias'); $this->assertEquals(1, $adapter->getClausesCount()); $adapter->resolveIdClause('xModel', 'yTableAlias'); $this->assertEquals(1, $adapter->getClausesCount()); $adapter->resolveIdClause('xModel', 'zTableAlias'); $this->assertEquals(2, $adapter->getClausesCount()); }