/** * @param string $modelClassName * @param array $concatedAttributeNames * @param RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter * @param null | string $onTableAliasName * @return array */ protected static function makeTableAliasAndColumnNamesForNonRelatedConcatedAttributes($modelClassName, $concatedAttributeNames, $joinTablesAdapter, $onTableAliasName = null) { assert('is_string($modelClassName)'); assert('is_array($concatedAttributeNames) && count($concatedAttributeNames) == 2'); assert('$joinTablesAdapter instanceof RedBeanModelJoinTablesQueryAdapter'); assert('is_string($onTableAliasName) || $onTableAliasName == null'); $tableAliasAndColumnNames = array(); foreach ($concatedAttributeNames as $attributeName) { $modelAttributeToDataProviderAdapter = new RedBeanModelAttributeToDataProviderAdapter($modelClassName, $attributeName); $builder = new ModelWhereAndJoinBuilder($modelAttributeToDataProviderAdapter, $joinTablesAdapter, true); $tableAliasName = $builder->resolveJoins($onTableAliasName, self::resolveCanUseFromJoins($onTableAliasName)); $tableAliasAndColumnNames[] = array($tableAliasName, $modelAttributeToDataProviderAdapter->getColumnName()); } return $tableAliasAndColumnNames; }
/** * After work on reporting branch, this test was breaking. So we switched the test to show left joins as * 0. This might be ok, just depends how you are using the adapter. Normally you would add more * filters in which case a join would be added if you are filtering on something specific with industry * @depends testResolveShouldAddFromTableWithAttributeOnModelSameTable */ public function testResolveShouldAddFromTableWithOwnedCustomFieldAttribute() { $adapter = new RedBeanModelAttributeToDataProviderAdapter('Account', 'industry'); $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Account'); $builder = new ModelWhereAndJoinBuilder($adapter, $joinTablesAdapter, true); $tableAliasName = $builder->resolveJoins(); $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount()); $this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount()); $adapter = new RedBeanModelAttributeToDataProviderAdapter('Account', 'industry'); $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Account'); $builder = new ModelWhereAndJoinBuilder($adapter, $joinTablesAdapter, false); $tableAliasName = $builder->resolveJoins(); $this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount()); $this->assertEquals(0, $joinTablesAdapter->getLeftTableJoinCount()); }
public function __construct(ReadOptimizationDerivedAttributeToDataProviderAdapter $modelAttributeToDataProviderAdapter, RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter) { parent::__construct($modelAttributeToDataProviderAdapter, $joinTablesAdapter); }