Skip to content
Permalink
Browse files

Fixed tests in postgres

This meant that the internal subquery table alias is leaked to the external query
and columns are not quoted anymore so that they can be referenced seemlessly in
conditions without having adress the column alias.
  • Loading branch information...
lorenzo committed Sep 12, 2014
1 parent 934479d commit 506342a5953c56af5b7b65a1300fe1d30d0a980a
@@ -124,12 +124,13 @@ protected function _buildQuery($options) {
}
public function _addFilteringJoin($query, $key, $subquery) {
$filter = [];
$aliasedTable = uniqid('c');
$filter = $fields = [];
$aliasedTable = $subquery->repository()->alias();
foreach ($subquery->clause('select') as $aliasedField => $field) {
$filter[] = new IdentifierExpression("$aliasedTable.$aliasedField");
$filter[] = new IdentifierExpression($field);
}
$subquery->select($filter, true);
if (is_array($key)) {
$conditions = $this->_createTupleCondition($query, $key, $filter, '=');
@@ -136,7 +136,7 @@ public function testHasManyEager($strategy) {
$results = $query->repository($table)
->select()
->contain(['SiteArticles' => ['conditions' => ['id' => 2]]])
->contain(['SiteArticles' => ['conditions' => ['SiteArticles.id' => 2]]])
->hydrate(false)
->toArray();
$expected[0]['articles'] = [];
@@ -244,7 +244,7 @@ public function testHasManyEagerLoadingNoHydration($strategy) {
$results = $query->repository($table)
->select()
->contain(['articles' => ['conditions' => ['id' => 2]]])
->contain(['articles' => ['conditions' => ['articles.id' => 2]]])
->hydrate(false)
->toArray();
$expected[0]['articles'] = [];
@@ -299,7 +299,7 @@ public function testHasManyEagerLoadingFieldsAndOrderNoHydration($strategy) {
->contain([
'articles' => [
'fields' => ['title', 'author_id'],
'sort' => ['id' => 'DESC']
'sort' => ['articles.id' => 'DESC']
]
])
->hydrate(false)
@@ -576,7 +576,7 @@ public function testBelongsToManyEagerLoadingNoHydration($strategy) {
$this->assertEquals($expected, $results);
$results = $query->select()
->contain(['Tags' => ['conditions' => ['id' => 3]]])
->contain(['Tags' => ['conditions' => ['Tags.id' => 3]]])
->hydrate(false)
->toArray();
$expected = [

0 comments on commit 506342a

Please sign in to comment.
You can’t perform that action at this time.