Doctrine 1
  1. Doctrine 1
  2. DC-674

NULL Dates are translated to '0000-00-00' after upgrading to 1.2.2

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1, 1.2.2
    • Fix Version/s: 1.2.1, 1.2.2
    • Component/s: Behaviors
    • Labels:
      None
    • Environment:
      Zend Framework, Ubuntu 9.10, MySQL

      Description

      Once the upgrade was done from Doctrine 1.2.1 to 1.2.2 we discovered that date related issues started to appear.
      With dates that are persisted in DB as NULL are translated to "0000-00-00" when retrieved from DB. This has occurred in multiple places and is quite worrying as there is a lot of dates in our project. This means that everywhere in our codebase where we check a datevalue in our Models is NULL we need also to check for the string literal "0000-00-00".

        Activity

        Ville Itämaa created issue -
        Ville Itämaa made changes -
        Field Original Value New Value
        Summary NULL Dates are translated to '0000-00-00' NULL Dates are translated to '0000-00-00' after upgrading to 1.2.2
        Affects Version/s 1.2.2 [ 10047 ]
        Affects Version/s 1.2.1 [ 10044 ]
        Environment Zend Framework, Ubuntu 9.10, MySQL
        Description Once the upgrade was done from Doctrine 1.2.1 to 1.2.2 we discovered that date related issues started to appear.
        With dates that are persisted in DB as NULL are translated to "0000-00-00" when retrieved from DB. This has occurred in multiple places and is quite worrying as there is a lot of dates in our project. This means that everywhere in our codebase where we check a datevalue in our Models is NULL we need also to check for the string literal "0000-00-00".

        Priority Major [ 3 ] Critical [ 2 ]
        Fix Version/s 1.2.2 [ 10047 ]
        Fix Version/s 1.2.1 [ 10044 ]
        Component/s Behaviors [ 10017 ]
        Hide
        Jonathan H. Wage added a comment -

        Are you able to reproduce this in a test case?

        Show
        Jonathan H. Wage added a comment - Are you able to reproduce this in a test case?
        Hide
        Ville Itämaa added a comment -

        We reverted to Doctrine 1.2.1 after realising the bug to confirm it was Doctrine 1.2.2 that was the cause for the problem. And as a result the records with NULL dates in the DB became NULL in the Models.
        But when using Doctrine 1.2.2, the NULL dates became '0000-00-00' in the Models.
        I don't have any other way to reproduce this error.

        Show
        Ville Itämaa added a comment - We reverted to Doctrine 1.2.1 after realising the bug to confirm it was Doctrine 1.2.2 that was the cause for the problem. And as a result the records with NULL dates in the DB became NULL in the Models. But when using Doctrine 1.2.2, the NULL dates became '0000-00-00' in the Models. I don't have any other way to reproduce this error.
        Hide
        Jonathan H. Wage added a comment -

        Were you able to identity which changeset it was? You can read about creating test cases here http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing

        So far I am not able to reproduce the error you described.

        Show
        Jonathan H. Wage added a comment - Were you able to identity which changeset it was? You can read about creating test cases here http://www.doctrine-project.org/documentation/manual/1_2/en/unit-testing So far I am not able to reproduce the error you described.
        Hide
        Jonathan H. Wage added a comment -

        I'd like to fix this. Did you ever figure out which changeset introduced the issue? I've been trying to figure it out myself.

        Show
        Jonathan H. Wage added a comment - I'd like to fix this. Did you ever figure out which changeset introduced the issue? I've been trying to figure it out myself.
        Roland Huszti made changes -
        Comment [ I just tested this with Doctrine 1.2.3, and it works fine for me. Maybe the base models are missing some parameter.

        {noformat}

        YAML

        fieldname:
                    type: timestamp(25)
                    notnull: false
                    default: null

        BASE MODEL

                $this->hasColumn('fieldname', 'timestamp', 25, array(
                     'type' => 'timestamp',
                     'notnull' => false,
                     /* 'default' => null, */ /* works fine without this */
                     'length' => '25',
                     ));

        {noformat} ]
        Hide
        Roland Huszti added a comment - - edited

        With 1.2.3 this works for me fine with both TIMESTAMP and DATE fields.

        YAML
        
                date_of_birth:
                    type: date
        
        BASE MODEL
        
                $this->hasColumn('date_of_birth', 'date', null, array(
                     'type' => 'date',
        
                     // try these two
                     // 'notnull' => false,
                     // 'default' => null
                 ));
        
        YAML
        
                exported_at:
                    type: timestamp(25)
                    notnull: false
                    default: null
        
                    # in this model I have everything to make sure it accepts and defaults to NULL
        
        BASE MODEL
        
                $this->hasColumn('exported_at', 'timestamp', 25, array(
                     'type' => 'timestamp',
                     'notnull' => false,
                     'length' => '25',
                     ));
        

        You may try adding these to your YAML and (base) models

        YAML
        
            fieldname:
                 . . .
                notnull: false
                default: null
        
        BASE MODEL
        
                $this->hasColumn('fieldname', . . .
                     . . .
                     'notnull' => false, // <<<<<<<
                     // 'default' => null, // <<< maybe, probably not needed
                     ));
        
        

        I hope it helps.

        Show
        Roland Huszti added a comment - - edited With 1.2.3 this works for me fine with both TIMESTAMP and DATE fields. YAML date_of_birth: type: date BASE MODEL $this->hasColumn('date_of_birth', 'date', null, array( 'type' => 'date', // try these two // 'notnull' => false, // 'default' => null )); YAML exported_at: type: timestamp(25) notnull: false default: null # in this model I have everything to make sure it accepts and defaults to NULL BASE MODEL $this->hasColumn('exported_at', 'timestamp', 25, array( 'type' => 'timestamp', 'notnull' => false, 'length' => '25', )); You may try adding these to your YAML and (base) models YAML fieldname: . . . notnull: false default: null BASE MODEL $this->hasColumn('fieldname', . . . . . . 'notnull' => false, // <<<<<<< // 'default' => null, // <<< maybe, probably not needed )); I hope it helps.

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DC-674, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Ville Itämaa
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: