Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2747

Doctrine Checking Null but not default

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Environment:
      FreeBSD, PHP 5.4.13, MySQL 5.6.10

      Description

      Doctrine ORM checks fields for the acceptance of null values on entity commits. It does not, however, check if those same fields allow have default values. Our DBA likes to specify not-null, in addition to a default, so that a manual entry of a null value cannot take place. It seems that Doctrine should check that the field has a default value after it checks if it accepts null, in order to prevent errors on not-null fields with default values that are not passed explicit values.

        Activity

        Hide
        Marco Pivetta added a comment -

        Clay Garland this is not up to doctrine to check. If your schema enforces non-null fields, so should your object graph do as well.

        That means that your setters or constructors should guarantee consistent state of the properties in your entities at any time, regardless of the ORM.

        Show
        Marco Pivetta added a comment - Clay Garland this is not up to doctrine to check. If your schema enforces non-null fields, so should your object graph do as well. That means that your setters or constructors should guarantee consistent state of the properties in your entities at any time, regardless of the ORM.
        Hide
        Marco Pivetta added a comment -

        Also a side-note: the ORM always assumes that your data is valid. It just limits itself to saving and loading it.

        Show
        Marco Pivetta added a comment - Also a side-note: the ORM always assumes that your data is valid. It just limits itself to saving and loading it.
        Hide
        Clay Garland added a comment -

        Thank you for the clarification, I got a ticket from a dev and our DBA said it was doctrine was throwing the error, but now that I've looked at the Entity, he has no default value assigned to his private variable and doctrine is just doing what it's told.

        Clay

        Show
        Clay Garland added a comment - Thank you for the clarification, I got a ticket from a dev and our DBA said it was doctrine was throwing the error, but now that I've looked at the Entity, he has no default value assigned to his private variable and doctrine is just doing what it's told. Clay

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Clay Garland
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: