This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Symfony wants to create null object in database

Discussion relating to version 1.3.x and 1.4.x

Symfony wants to create null object in database

by latata » Mon Sep 08, 2014 9:28 am

I work on symfony 1.4 (doctrine) project. I've added relation to my sfGuardUserProfile model:

Code: Select all
sfGuardUserProfile:
          tableName: sf_guard_user_profile
          columns:
            id:                     { type: integer(20), primary: true, autoincrement: true }
            user_id:                { type: integer(20), notnull: true }
            username:               { type: string(128), notnull: false }
            ...
    city:                   { type: string(255) }
            ...
          relations:
            User:
              class: sfGuardUser
              foreign: id
              local: user_id
              type: one
              onDelete: cascade
              foreignType: one
              foreignAlias: Profile
            ...
            RelatedCity:
              class:          City
              local:          city
              foreign:        woeid
              onDelete:       cascade
              type:           one


Now, when I try to save sfGuardUserProfile object (city value is null) it tries to create new record in cities table with all fields null and I get an sql exception `Column country_id cannot be null`. country_id is a field in city table (and model). How to prevent inserting this null city object?

Screenshot of exception: http://screencast.com/t/Lw4m909L7Y8w
latata
Junior Member
 
Posts: 1
Joined: Mon Sep 08, 2014 9:26 am