Skip to content
This repository

Bugfix for join equality when default join type is used #638

Merged
merged 1 commit into from over 1 year ago

3 participants

Kamil Dziedzic Markus Staab William Durand
Kamil Dziedzic

Since http://trac.propelorm.org/changeset/1959#file1 there is a bug in checking equality between two joins if you skip joinType parameter so below won't work:

$j1 = new Join('foo', 'bar');
$j2 = new Join('foo', 'bar', 'INNER JOIN');
$this->assertTrue($j1->equals($j2));

The change to bugfix this is simple, I've also added tests for other, currently working test cases.

Kamil Dziedzic arvenil Bugfix for join equality when default join type is used
$j1 = new Join('foo', 'bar');
$j2 = new Join('foo', 'bar', 'INNER JOIN');
$this->assertTrue($j1->equals($j2));
dcace44
Markus Staab
Collaborator

LGTM

William Durand willdurand merged commit 6407158 into from
William Durand
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 27, 2013
Kamil Dziedzic arvenil Bugfix for join equality when default join type is used
$j1 = new Join('foo', 'bar');
$j2 = new Join('foo', 'bar', 'INNER JOIN');
$this->assertTrue($j1->equals($j2));
dcace44
This page is out of date. Refresh to see the latest.
5 runtime/lib/query/Join.php
@@ -226,8 +226,7 @@ public function setJoinType($joinType = null)
226 226 /**
227 227 * Get the join type
228 228 *
229   - * @return string The type of the join, i.e. Criteria::LEFT_JOIN(), ...,
230   - * or null for adding the join condition to the where Clause
  229 + * @return string The type of the join, i.e. Criteria::LEFT_JOIN()
231 230 */
232 231 public function getJoinType()
233 232 {
@@ -548,7 +547,7 @@ public function equals($join)
548 547 {
549 548 return $join !== null
550 549 && $join instanceof Join
551   - && $this->joinType == $join->getJoinType()
  550 + && $this->getJoinType() == $join->getJoinType()
552 551 && $this->getConditions() == $join->getConditions();
553 552 }
554 553
22 test/testsuite/runtime/query/JoinTest.php
@@ -165,6 +165,28 @@ public function testCompositeeConstructor()
165 165 $this->assertEquals('LEFT JOIN', $j->getJoinType());
166 166 }
167 167
  168 + public function testEquality() {
  169 + $j1 = new Join('foo', 'bar', 'INNER JOIN');
  170 +
  171 + $j2 = new Join('foo', 'bar', 'INNER JOIN');
  172 + $this->assertTrue($j1->equals($j2));
  173 +
  174 + $j3 = new Join('foo', 'bar', 'LEFT JOIN');
  175 + $this->assertFalse($j1->equals($j3), 'INNER JOIN is not equal to LEFT JOIN');
  176 +
  177 + $j4 = new Join('foo', 'bar', 'RIGHT JOIN');
  178 + $this->assertFalse($j1->equals($j4), 'INNER JOIN is not equal to RIGHT JOIN');
  179 +
  180 + $j5 = new Join('foo', 'bar');
  181 + $j6 = new Join('foo', 'bar');
  182 + $this->assertTrue($j5->equals($j6), 'Joins without specified join type should be equal,
  183 + as they fallback to default join type');
  184 +
  185 + $j7 = new Join('foo', 'bar', 'INNER JOIN');
  186 + $this->assertTrue($j5->equals($j7), 'Join without specified join type should be equal
  187 + to INNER JOIN, as it fallback to default join type');
  188 + }
  189 +
168 190 public function testCountConditions()
169 191 {
170 192 $j = new Join();

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.