Changeset 5296

Show
Ignore:
Timestamp:
12/17/08 20:38:36 (7 months ago)
Author:
jwage
Message:

[1.0, 1.1] Fixes issue with validators not passing when a related object is set for a foreign key and the foreign key field is notnull (closes #1755)

Location:
branches
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/Table.php

    r5280 r5296  
    16761676        if ($value === self::$_null) { 
    16771677            $value = null; 
    1678         } else if ($value instanceof Doctrine_Record) { 
     1678        } else if ($value instanceof Doctrine_Record && $value->exists()) { 
    16791679            $value = $value->getIncremented(); 
     1680        } else if ($value instanceof Doctrine_Record && ! $value->exists()) { 
     1681            foreach($this->getRelations() as $relation) { 
     1682                if($fieldName == $relation->getLocalFieldName() && get_class($value) == $relation->getClass()) { 
     1683                    return $errorStack; 
     1684                } 
     1685            } 
    16801686        } 
    16811687 
  • branches/1.0/tests/run.php

    r5168 r5296  
    183183$validators->addTestCase(new Doctrine_Validator_Future_TestCase()); 
    184184$validators->addTestCase(new Doctrine_Validator_Past_TestCase()); 
     185$validators->addTestCase(new Doctrine_Validator_ForeignKeys_TestCase()); 
    185186$test->addTestCase($validators); 
    186187 
  • branches/1.1/lib/Doctrine/Table.php

    r5280 r5296  
    17361736        if ($value === self::$_null) { 
    17371737            $value = null; 
    1738         } else if ($value instanceof Doctrine_Record) { 
     1738        } else if ($value instanceof Doctrine_Record && $value->exists()) { 
    17391739            $value = $value->getIncremented(); 
     1740        } else if ($value instanceof Doctrine_Record && ! $value->exists()) { 
     1741            foreach($this->getRelations() as $relation) { 
     1742                if($fieldName == $relation->getLocalFieldName() && get_class($value) == $relation->getClass()) { 
     1743                    return $errorStack; 
     1744                } 
     1745            } 
    17401746        } 
    17411747 
  • branches/1.1/tests/run.php

    r5166 r5296  
    185185$validators->addTestCase(new Doctrine_Validator_Future_TestCase()); 
    186186$validators->addTestCase(new Doctrine_Validator_Past_TestCase()); 
     187$validators->addTestCase(new Doctrine_Validator_ForeignKeys_TestCase()); 
    187188$test->addTestCase($validators); 
    188189