Ticket #1280 (closed defect: fixed)

Opened 11 months ago

Last modified 10 months ago

Can't unset one-to-many relation on the "one" side

Reported by: pstradomski Owned by: romanb
Priority: major Milestone:
Component: Relations Version: 1.0.0
Severity: Keywords:
Cc: pstradomski@… Has Test: no
Status: Pending Core Response Has Patch: no

Description

Group has many Users.

The GroupId? field is nullable

$user->Group = $group;
$user->save();

Now none of the below work:

$user->Group = null;
unset($user->Group)
$user->unlink('Group')

The first one fails immediately, the second and third attempt to delete the group instead of setting GroupId? to NULL. It is only possible to use $user->GroupId = null, but this does not remove the relation, so isset($user->Group) still returns true.

Change History

Changed 11 months ago by pstradomski

Update: with latest 0.11 and 1.0 versions (svn checkout) $user->Group removes the relation from the object, but does not affect GroupId? field. Currently I have to do $user->Group = null; $user->GroupId = null;

Changed 11 months ago by jwage

  • version changed from 0.11 to 1.0
  • milestone changed from Unknown to 1.0.0-RC1

Changed 11 months ago by guilhermeblanco

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

(In [4778]) fixed #1280. Fixed Export that never deals with default=null in all DBMS. Also fixed $entity->Relation = null; situation that cleans the reference. Now we have unset and unlink that deletes related object and = null that only defines the default value when save() is called.

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.