From ea629f839f59cbd2494dd5047815d5f39e8b50f1 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 12 Jun 2017 16:24:42 +0300 Subject: [PATCH 1/2] Fix issue #1388: broken model-only relationships --- src/Propel/Generator/Model/Table.php | 2 +- tests/Propel/Tests/Issues/Issue1388Test.php | 58 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/Propel/Tests/Issues/Issue1388Test.php diff --git a/src/Propel/Generator/Model/Table.php b/src/Propel/Generator/Model/Table.php index e89316c3bb..144e933426 100644 --- a/src/Propel/Generator/Model/Table.php +++ b/src/Propel/Generator/Model/Table.php @@ -791,7 +791,7 @@ public function setupReferrers($throwErrors = false) $foreignPrimaryKeys = $foreignTable->getPrimaryKey(); // check all keys are referenced in foreign key foreach ($foreignPrimaryKeys as $foreignPrimaryKey) { - if (!$foreignPrimaryKey->hasReferrer($foreignKey) && $throwErrors) { + if (!$foreignPrimaryKey->hasReferrer($foreignKey) && !$foreignKey->isSkipSql() && $throwErrors) { // foreign primary key is not being referenced in foreign key throw new BuildException(sprintf( 'Table "%s" contains a foreign key to table "%s" but does not have a reference to foreign primary key "%s"', diff --git a/tests/Propel/Tests/Issues/Issue1388Test.php b/tests/Propel/Tests/Issues/Issue1388Test.php new file mode 100644 index 0000000000..0c136db789 --- /dev/null +++ b/tests/Propel/Tests/Issues/Issue1388Test.php @@ -0,0 +1,58 @@ + + + + + + + + + + +
+ + + + + + + +
+
+EOF; + + $builder = new QuickBuilder(); + $builder->setSchema($schema); + + try { + $builder->buildClasses(null, true); + $noExceptionThrown = true; + } catch (\Exception $e) { + $noExceptionThrown = false; + } + + $this->assertTrue($noExceptionThrown); + + } +} \ No newline at end of file From 3d61fefe8595483ee6fe8868da2b2d313148880c Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 12 Jun 2017 16:49:27 +0300 Subject: [PATCH 2/2] simplified test --- tests/Propel/Tests/Issues/Issue1388Test.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/Propel/Tests/Issues/Issue1388Test.php b/tests/Propel/Tests/Issues/Issue1388Test.php index 0c136db789..da6b500c1f 100644 --- a/tests/Propel/Tests/Issues/Issue1388Test.php +++ b/tests/Propel/Tests/Issues/Issue1388Test.php @@ -44,15 +44,6 @@ public function testSkippedIncompleteForeignReference() $builder = new QuickBuilder(); $builder->setSchema($schema); - - try { - $builder->buildClasses(null, true); - $noExceptionThrown = true; - } catch (\Exception $e) { - $noExceptionThrown = false; - } - - $this->assertTrue($noExceptionThrown); - + $builder->buildClasses(null, true); } } \ No newline at end of file