cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG]: Model add and next remove related

Open zak-wojtek77 opened this issue 6 years ago • 1 comments

Describe the bug If exitsts entity A and has many entities B

class A extends Model
{
    public function initialize()
    {
        $this->hasMany(
            'id',
            B::class,
            'a_id',
            'manyB'
        );
    }
}
class B extends Model
{
    // ...
}

and is such code:

$a = \A::findFirst();
$b = new \B();
$a->manyB = [$b];
// now should be like at the beginning
// but is not
// because $dirtyRelated is not empty
$a->manyB = [];
$result = $a->save();
// FALSE because try save related $b
var_dump($result);

Expected behavior In above case $result should be TRUE

Details

  • Phalcon version: 4.0.0 (4.0.3)
  • PHP Version: 7.2
  • Operating System: Debian (docker)
  • Installation type: Compiling from source
  • Server: Nginx
  • Other related info (Database, table schema): MySQL 5.5

zak-wojtek77 avatar Feb 07 '20 08:02 zak-wojtek77

Fixed in #15165

zsilbi avatar Oct 16 '20 20:10 zsilbi