Doctrine 1
  1. Doctrine 1
  2. DC-648

Behavior geographical generates latitude DOUBLE(18, 2), longitude DOUBLE(18, 2) - it's not exact

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: Behaviors
    • Labels:
      None
    • Environment:
      Doctrine 1.2.2

      Description

      The problem was already described by another person at http://www.doctrine-project.org/jira/browse/DC-385
      and was fixed but now is broken again.

      When using the Geographical behaviour in a YML schema the latitude is stored in Mysql as a Double(18,2) instead of a Double as it was in the previous versions. It appears that all doubles in yml are defaulting to (18,2).

      1. patch.diff
        1 kB
        khim tieu-philippe

        Activity

        Hide
        Malcolm Hall added a comment -

        The problem lies in DataDict/Mysql.php

        Previously it was:

        case 'double':
        return 'DOUBLE';

        now it's:

        case 'double':
        $length = !empty($field['length']) ? $field['length'] : 18;
        $scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine_Core::ATTR_DECIMAL_PLACES);
        return 'DOUBLE('.$length.', '.$scale.')';

        Perhaps this could be improved so that if there is no length specified it returns just double with no length or scale instead of defaulting to 18, ATTR_DECIMAL_PLACES? I expect that most people that use the double type in yaml wouldn't want only 2 decimals.

        Show
        Malcolm Hall added a comment - The problem lies in DataDict/Mysql.php Previously it was: case 'double': return 'DOUBLE'; now it's: case 'double': $length = !empty($field ['length'] ) ? $field ['length'] : 18; $scale = !empty($field ['scale'] ) ? $field ['scale'] : $this->conn->getAttribute(Doctrine_Core::ATTR_DECIMAL_PLACES); return 'DOUBLE('.$length.', '.$scale.')'; Perhaps this could be improved so that if there is no length specified it returns just double with no length or scale instead of defaulting to 18, ATTR_DECIMAL_PLACES? I expect that most people that use the double type in yaml wouldn't want only 2 decimals.
        Hide
        Jonathan H. Wage added a comment -

        Can you provide a patch that fixes the situation for you? we'll see if that has any breakage of current tests.

        Show
        Jonathan H. Wage added a comment - Can you provide a patch that fixes the situation for you? we'll see if that has any breakage of current tests.
        Hide
        khim tieu-philippe added a comment -

        I have the same trouble, and I fix it by specified directly the precision of the double into Doctrine_Template_Geographical class.

        'type' => 'double(18,8)',

        Show
        khim tieu-philippe added a comment - I have the same trouble, and I fix it by specified directly the precision of the double into Doctrine_Template_Geographical class. 'type' => 'double(18,8)',
        Hide
        Janusz Slota added a comment - - edited

        You can fix it with:
        Geographical:
          latitude:
            type: float(18,8)
          longitude:
            type: float(18,8)

        instead of:
        Geographical: ~

        Show
        Janusz Slota added a comment - - edited You can fix it with: Geographical:   latitude:     type: float(18,8)   longitude:     type: float(18,8) instead of: Geographical: ~
        Hide
        khim tieu-philippe added a comment -

        diff on Template/Geographical.php

        Hope that could help

        Show
        khim tieu-philippe added a comment - diff on Template/Geographical.php Hope that could help

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Malcolm Hall
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: