Ticket #1481 (closed defect: fixed)

Opened 10 months ago

Last modified 9 months ago

Application-level cascade definition via YML doesn't work.

Reported by: nodkz Owned by: jwage
Priority: major Milestone: 1.0.3
Component: Schema Files Version: 1.0.0
Severity: Keywords: yml, shema, cascade
Cc: Has Test: no
Status: Pending Core Response Has Patch: yes

Description

    BillItem:                                        
      local: id
      foreign: bill_id
      type: many
      cascade: [delete]   # <-- BUILDER does not write in {object}Base.php this line

It is not copy of ticket #1234.

Builder does not write in {object}Base.php this line {... 'cascade' => array('delete') ... }

Error in following method Doctrine_Import_Builder::buildSetUp(). There ara nothing about cascade.

                if (isset($relation['refClass'])) {
                    $a[] = ''refClass' => ' . $this->varExport($relation['refClass']);
                }

                if (isset($relation['deferred']) && $relation['deferred']) {
                    $a[] = ''default' => ' . $this->varExport($relation['deferred']);
                }

                if (isset($relation['local']) && $relation['local']) {
                    $a[] = ''local' => ' . $this->varExport($relation['local']);
                }

                if (isset($relation['foreign']) && $relation['foreign']) {
                    $a[] = ''foreign' => ' . $this->varExport($relation['foreign']);
                }

                if (isset($relation['onDelete']) && $relation['onDelete']) {
                    $a[] = ''onDelete' => ' . $this->varExport($relation['onDelete']);
                }

                if (isset($relation['onUpdate']) && $relation['onUpdate']) {
                    $a[] = ''onUpdate' => ' . $this->varExport($relation['onUpdate']);
                }

                if (isset($relation['equal']) && $relation['equal']) {
                    $a[] = ''equal' => ' . $this->varExport($relation['equal']);
                }

                if (isset($relation['owningSide']) && $relation['owningSide']) {
                    $a[] = ''owningSide' => ' . $this->varExport($relation['owningSide']);
                }

                if ( ! empty($a)) {
                    $ret[$i] .= ', ' . 'array(';
                    $length = strlen($ret[$i]);
                    $ret[$i] .= implode(',' . PHP_EOL . str_repeat(' ', $length), $a) . ')';
                }




NEED append after owningSide:

                if (isset($relation['cascade']) && $relation['cascade']) {
                    $a[] = ''cascade' => ' . $this->varExport($relation['cascade']);
                }

Change History

Changed 10 months ago by ctigglet

I think your syntax is incorrect. It should be as follows:

BillItem:
  local: id
  foreign: bill_id
  type: many
  onDelete: CASCADE   # <-- BUILDER does not write in {object}Base.php this line

You'll notice in the code you excerpted that "onDelete" is already handled.

Changed 10 months ago by romanb

He is referring to application-level cascades, not to database foreign-key cascades.

Changed 9 months ago by ctigglet

Ooops. My bad. Still learning...

Changed 9 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

In r4980 this was fixed. Thanks for the report.

Note: See TracTickets for help on using tickets.