#1547: Saving an object creates unnecesary NULL related object
-----------------------------------+----------------------------------------
 Reporter:  jpsaraceno             |       Owner:  romanb 
     Type:  defect                 |      Status:  new    
 Priority:  critical               |   Milestone:  Unknown
Component:  Record                 |     Version:  1.0.2  
 Keywords:                         |    Has_test:  0      
 Mystatus:  Pending Core Response  |   Has_patch:  0      
-----------------------------------+----------------------------------------
 Got the following entities on my schema definition:
 {{{
 Location:
   actAs:                  [Geographical]
   columns:
     id:                   { type: integer, primary: true, autoincrement:
 true }
     name:                 string(255)

 User:
   actAs:                    { Timestampable SoftDelete }
   columns:
     id:                     { type: integer, primary: true, autoincrement:
 true }
     login:                  string(255)
     email:                  string(255)
     phone_number:           string(255)
     crypted_password:       string(255)
     location_id:            integer
   relations:
     Location:               { class: Location }
 }}}

 So, a user may have one location, but is also acceptable for a user to
 have no location set.

 Now, when creating a User, I'm doing something like:
 {{{
 $user = new User();
 $user->setEmail('[EMAIL PROTECTED]');
 $user->setPhoneNumber('1234567890'));
 //some more setSomething() here, but NEVER doing anything related to the
 location
 $user->save();
 }}}

 Doctrine creates the expected record on the user table, but instead also
 creates a record on the location table, with just the id and all NULL
 values.
 I would expect the user to be created with location_id=NULL and no record
 on the location table.

 I tried to explicitly unset the user location (three different ways
 $user->setLocation(NULL), $user->setLocationId(NULL) and
 $user->unlink('Location') ) with no luck: still getting the all-null
 location created.

 Am I doing something wrong? Or this is just a bug on Doctrine?

 I'm using Doctrine's symfony plugin for the 1.1 Symfony version.

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1547>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to