Doctrine 1
  1. Doctrine 1
  2. DC-164

Validator throws out a 'boolean' with null value.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0-BETA1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Fedora 10, symfony 1.2, php 5.2.9, postgresql 8.4.1, can't tell what version of Doctrine I have.

      Description

      I didn't set a value into a boolean column, reckoning that null would count as false.

      But saving the record fails validation, and this appears to be because Doctrine_Validator::isValidType contains

      case 'boolean':
      return is_bool($var) || (is_numeric($var) && ($var == 0 || $var == 1));

      So it will not accept a null value, and furthermore reports the failure not as a data error but (confusingly) as a type error.

      I checked the documentation to see if it said that I could not use a null value (I would regard this as an unnecessary restriction, but at least if it were documented, that would be consistent).

      On the contrary, the Doctrine ORM book, Chapter 7, in the 'Boolean' section, says "Ternary logic is possible by using null as the third possible value that may be assigned to fields of this type."!

      Add this to the fact that I haven't found any documentation about using Doctrine_Validator_Exception - not even API documentation, and I am not impressed with my first experiences with Doctrine.

        Activity

        Hide
        Roman S. Borschel added a comment - - edited

        This is the wrong project. Please submit these bugs to the Doctrine1 project. I already moved the 2 tickets you created. Just create any more in the Doctrine 1 project.

        Show
        Roman S. Borschel added a comment - - edited This is the wrong project. Please submit these bugs to the Doctrine1 project. I already moved the 2 tickets you created. Just create any more in the Doctrine 1 project.
        Hide
        Jonathan H. Wage added a comment -

        This is already fixed in Doctrine 1.2 as well.

        Show
        Jonathan H. Wage added a comment - This is already fixed in Doctrine 1.2 as well.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Colin Fine
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: