Index: tests/Zend/Db/Table/TestCommon.php =================================================================== --- tests/Zend/Db/Table/TestCommon.php (revision 24462) +++ tests/Zend/Db/Table/TestCommon.php (working copy) @@ -1652,9 +1652,44 @@ $this->assertEquals(1, count($rowset)); } + /** + * @group ZF-3144 + */ + public function testCascadingOperationReferenceColumnFallsBackToPrimaryKeyWhenNotSpecified() + { + Zend_Db_Table::setDefaultAdapter($this->_db); + + $this->_util->createTable('ZF3144_products', array( + 'id' => 'tinyint(4) NOT NULL', + 'PRIMARY KEY' => 'id' + )); + + $this->_util->createTable('ZF3144_files', array( + 'id' => 'tinyint(4) NOT NULL', + 'productId' => 'tinyint(4) NOT NULL', + 'PRIMARY KEY' => 'id' + )); + + require_once dirname(__FILE__) . "/_files/My/ZF3144/Products.php"; + $tblProducts = new My_ZF3144_Products(); + $tblProducts->createRow(array('id'=>1))->save(); + $tblProducts->createRow(array('id'=>2))->save(); + require_once dirname(__FILE__) . "/_files/My/ZF3144/Files.php"; + $tblFiles = new My_ZF3144_Files(); + $tblFiles->createRow(array('id'=>7, 'productId'=>2))->save(); + $tblFiles->createRow(array('id'=>8, 'productId'=>2))->save(); + + $tblProducts->find(2)->current()->delete(); + + $this->_util->dropTable('ZF3144_products'); + $this->_util->dropTable('ZF3144_files'); + + Zend_Db_Table::setDefaultAdapter(); + } + /** * Returns a clean Zend_Cache_Core with File backend * Index: tests/Zend/Db/Table/_files/My/ZF3144/Files.php =================================================================== --- tests/Zend/Db/Table/_files/My/ZF3144/Files.php (revision 0) +++ tests/Zend/Db/Table/_files/My/ZF3144/Files.php (revision 0) @@ -0,0 +1,48 @@ + array( + 'columns' => 'productId', + 'refTableClass' => 'My_ZF3144_Products', + // 'refColumns purposely omitted + 'onDelete' => self::CASCADE, + ), + ); +} Property changes on: tests/Zend/Db/Table/_files/My/ZF3144/Files.php ___________________________________________________________________ Added: svn:keywords + Id Index: tests/Zend/Db/Table/_files/My/ZF3144/Products.php =================================================================== --- tests/Zend/Db/Table/_files/My/ZF3144/Products.php (revision 0) +++ tests/Zend/Db/Table/_files/My/ZF3144/Products.php (revision 0) @@ -0,0 +1,52 @@ +