Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #356 from chmeliuk/illegal-offset-type

[BUG] Illegal offset type in /propel/runtime/lib/collection/PropelObjectCollection.php line 222
  • Loading branch information...
commit 82372dddcece94f06d3f6e0143ba9a6c0529f201 2 parents 28477fa + 8b9449a
@willdurand willdurand authored
View
3  generator/lib/builder/om/QueryBuilder.php
@@ -964,13 +964,14 @@ public function filterBy$relationName($objectName, \$comparison = null)
if (!$fk->isComposite()) {
$localColumnConstant = $this->getColumnConstant($fk->getLocalColumn());
$foreignColumnName = $fk->getForeignColumn()->getPhpName();
+ $keyColumn = $fk->getForeignTable()->hasCompositePrimaryKey() ? $foreignColumnName : 'PrimaryKey';
$script .= "
} elseif ($objectName instanceof PropelCollection) {
if (null === \$comparison) {
\$comparison = Criteria::IN;
}
return \$this
- ->addUsingAlias($localColumnConstant, {$objectName}->toKeyValue('PrimaryKey', '$foreignColumnName'), \$comparison);";
+ ->addUsingAlias($localColumnConstant, {$objectName}->toKeyValue('$keyColumn', '$foreignColumnName'), \$comparison);";
}
$script .= "
} else {";
View
15 test/fixtures/bookstore/schema.xml
@@ -377,4 +377,19 @@
<column name="name" type="VARCHAR" />
</table>
+ <table name="record_label">
+ <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" />
+ <column name="abbr" type="VARCHAR" size="5" primaryKey="true" required="true"/>
+ <column name="name" type="VARCHAR" />
+ </table>
+ <table name="release_pool">
+ <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" />
+ <column name="record_label_id" type="INTEGER" required="true"/>
+ <column name="name" type="VARCHAR" />
+ <foreign-key foreignTable="record_label" onDelete="cascade">
+ <reference local="record_label_id" foreign="id" />
+ </foreign-key>
+ </table>
+
+
</database>
View
27 test/testsuite/generator/builder/om/QueryBuilderTest.php
@@ -652,7 +652,7 @@ public function testFilterByFkObjectCollection()
$this->assertEquals($q2, $q1, 'filterByFk() accepts a collection and results to an IN query');
}
- public function testFilterByRefFk()
+ public function testFilterByRefFk()
{
$this->assertTrue(method_exists('BookQuery', 'filterByReview'), 'QueryBuilder adds filterByRefFk() methods');
$this->assertTrue(method_exists('BookQuery', 'filterByMedia'), 'QueryBuilder adds filterByRefFk() methods for all fkeys');
@@ -686,6 +686,31 @@ public function testFilterByRefFkSimpleKey()
$this->assertEquals($q1, $q, 'filterByRefFk() accepts an optional comparison operator');
}
+ public function testFilterByRelationNameCompositePk()
+ {
+ BookstoreDataPopulator::depopulate();
+ BookstoreDataPopulator::populate();
+
+ $testLabel = RecordLabelQuery::create()
+ ->limit(2)
+ ->find($this->con);
+
+ $testRelease = ReleasePoolQuery::create()
+ ->addJoin(ReleasePoolPeer::RECORD_LABEL_ID, RecordLabelPeer::ID)
+ ->filterByRecordLabel($testLabel)
+ ->find($this->con);
+ $q1 = $this->con->getLastExecutedQuery();
+
+ $releasePool = ReleasePoolQuery::create()
+ ->addJoin(ReleasePoolPeer::RECORD_LABEL_ID, RecordLabelPeer::ID)
+ ->add(ReleasePoolPeer::RECORD_LABEL_ID, $testLabel->toKeyValue('Id', 'Id'), Criteria::IN)
+ ->find($this->con);
+ $q2 = $this->con->getLastExecutedQuery();
+
+ $this->assertEquals($q2, $q1, 'filterBy{RelationName}() only accepts arguments of type {RelationName} or PropelCollection');
+ $this->assertEquals($releasePool, $testRelease);
+ }
+
public function testFilterByRefFkCompositeKey()
{
BookstoreDataPopulator::depopulate();
View
31 test/tools/helpers/bookstore/BookstoreDataPopulator.php
@@ -201,6 +201,37 @@ public static function populate($con = null)
$summary->setSummary("Harry Potter does some amazing magic!");
$summary->save();
+ // Add release_pool and record_label
+ $acuna = new RecordLabel();
+ $acuna->setAbbr('acuna');
+ $acuna->setName('Acunadeep');
+ $acuna->save();
+
+ $fade = new RecordLabel();
+ $fade->setAbbr('fade');
+ $fade->setName('Fade Records');
+ $fade->save();
+
+ $pool = new ReleasePool();
+ $pool->setName('D.Chmelyuk - Revert Me Back');
+ $pool->setRecordLabel($acuna);
+ $pool->save();
+
+ $pool = new ReleasePool();
+ $pool->setName('VIF & Lola Palmer - Dreamer');
+ $pool->setRecordLabel($acuna);
+ $pool->save();
+
+ $pool = new ReleasePool();
+ $pool->setName('Lola Palmer - Do You Belong To Me');
+ $pool->setRecordLabel($acuna);
+ $pool->save();
+
+ $pool = new ReleasePool();
+ $pool->setName('Chris Forties - Despegue (foem.info Runners Up Remixes)');
+ $pool->setRecordLabel($fade);
+ $pool->save();
+
$con->commit();
}
Please sign in to comment.
Something went wrong with that request. Please try again.