Doctrine 1
  1. Doctrine 1
  2. DC-275

Mysql Schema Manager does not correctly detect Decimal + bug fix from me

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-BETA3
    • Fix Version/s: 1.2.0
    • Component/s: Import/Export
    • Labels:
      None

      Description

      Mysql Schema Manager does not correctly detect Decimal. Lost decimal scale!

      bug in file Doctrine/DataDict/Mysql.php

      on line 263

       
              if (isset($field['length'])) {
                  $length = $field['length'];
                  $decimal = '';
              } else {
                  $length = strtok('(), ');
                  $decimal = strtok('(), ') ? strtok('(), '):null;    // <--- here strtok call 2 times! (line 263)
              }
      

      must be like that

       
              if (isset($field['length'])) {
                  $length = $field['length'];
                  $decimal = '';
              } else {
                  $length = strtok('(), ');
                  $decimal = strtok('(), ');
                  if ( ! $decimal ) { // or false === $decimal
                      $decimal = null;
                  }
              }
      

      Please fix it

        Activity

        Hide
        Sergei Kuznetsov added a comment -

        Code formating fix

        Show
        Sergei Kuznetsov added a comment - Code formating fix
        Hide
        Jonathan H. Wage added a comment -

        Sorry I don't understand your change at all Can you explain what you're doing? I am confused by this whole block of code:

                    $length = strtok('(), ');
                    $decimal = strtok('(), ') ? strtok('(), '):null;
        

        Won't that always have the same result? Shouldn't it be..

                    $length = null;
                    $decimal = null;
        
        Show
        Jonathan H. Wage added a comment - Sorry I don't understand your change at all Can you explain what you're doing? I am confused by this whole block of code: $length = strtok('(), '); $decimal = strtok('(), ') ? strtok('(), '): null ; Won't that always have the same result? Shouldn't it be.. $length = null ; $decimal = null ;
        Hide
        Jonathan H. Wage added a comment -

        Nevermind after testing that won't work. Can you explain to me what you're change is doing?

        Show
        Jonathan H. Wage added a comment - Nevermind after testing that won't work. Can you explain to me what you're change is doing?
        Hide
        Jonathan H. Wage added a comment -

        Ok I think I understand now. Can you comment and confirm what the change is doing.

        Show
        Jonathan H. Wage added a comment - Ok I think I understand now. Can you comment and confirm what the change is doing.
        Hide
        Sergei Kuznetsov added a comment -

        Ok, see:

        original code:

        $decimal = strtok('(), ') ? strtok('(), '):null;    // <--- here strtok call 2 times! (line 263)
        

        strtok call 2 times and after two call $decimal always === false

        fix:

        $decimal = strtok('(), '); 
        

        now strtok call 1 times and $decimal have valid value!

        and this code check strtok return result

         if ( ! $decimal ) { // or false === $decimal
                        $decimal = null;
                    } 
        
        Show
        Sergei Kuznetsov added a comment - Ok, see: original code: $decimal = strtok('(), ') ? strtok('(), '): null ; // <--- here strtok call 2 times! (line 263) strtok call 2 times and after two call $decimal always === false fix: $decimal = strtok('(), '); now strtok call 1 times and $decimal have valid value! and this code check strtok return result if ( ! $decimal ) { // or false === $decimal $decimal = null ; }

          People

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

            Dates

            • Created:
              Updated:
              Resolved: