Skip to content
Permalink
Browse files

Adding a quite important missing part to join generation in BelonsTo and

HasOne
  • Loading branch information...
lorenzo committed May 12, 2013
1 parent 22c3ced commit be991c6ee69470df37adcd5dee898e69af47cc21
@@ -74,7 +74,8 @@ public function attachTo(Query $query, array $options = []) {
'includeFields' => true,
'foreignKey' => $this->foreignKey(),
'conditions' => [],
'type' => $this->joinType()
'type' => $this->joinType(),
'table' => $target->table()
];
$options['conditions'] = array_merge($this->conditions(), $options['conditions']);
@@ -82,7 +82,8 @@ public function attachTo(Query $query, array $options = []) {
'includeFields' => true,
'foreignKey' => $this->foreignKey(),
'conditions' => [],
'type' => $this->joinType()
'type' => $this->joinType(),
'table' => $target->table()
];
$options['conditions'] = array_merge($this->conditions(), $options['conditions']);
@@ -87,6 +87,7 @@ public function testAttachTo() {
'Company.is_active' => true,
'Company.id = Client.company_id',
],
'table' => 'companies',
'type' => 'LEFT'
]
]);
@@ -115,7 +116,8 @@ public function testAttachToConfigOverride() {
'conditions' => [
'Company.is_active' => false
],
'type' => 'LEFT'
'type' => 'LEFT',
'table' => 'companies',
]
]);
$query->expects($this->once())->method('select')->with([
@@ -149,7 +151,8 @@ public function testAttachToNoFields() {
'Company.is_active' => true,
'Company.id = Client.company_id',
],
'type' => 'LEFT'
'type' => 'LEFT',
'table' => 'companies',
]
]);
$query->expects($this->never())->method('select');
@@ -87,7 +87,8 @@ public function testAttachTo() {
'Profile.is_active' => true,
'User.id = Profile.user_id',
],
'type' => 'INNER'
'type' => 'INNER',
'table' => 'profiles'
]
]);
$query->expects($this->once())->method('select')->with([
@@ -117,7 +118,8 @@ public function testAttachToConfigOverride() {
'conditions' => [
'Profile.is_active' => false
],
'type' => 'INNER'
'type' => 'INNER',
'table' => 'profiles'
]
]);
$query->expects($this->once())->method('select')->with([
@@ -151,7 +153,8 @@ public function testAttachToNoFields() {
'Profile.is_active' => true,
'User.id = Profile.user_id',
],
'type' => 'INNER'
'type' => 'INNER',
'table' => 'profiles'
]
]);
$query->expects($this->never())->method('select');

0 comments on commit be991c6

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