Doctrine 1
  1. Doctrine 1
  2. DC-385

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.2
    • Component/s: Behaviors
    • Labels:
      None
    • Environment:
      symfony 1.4.1 / mysql

      Description

      The problem was already described by another person at http://trac.symfony-project.org/ticket/7763
      the generated field-type is wrong, so the stored lat/long values have lost precision.

        Activity

        Hide
        Hash added a comment -

        This change doesn't fix the problem. The problem here is that float and double types default to (18,2) for no good reason. See line 233: http://trac.doctrine-project.org/browser/branches/1.2/lib/Doctrine/DataDict/Mysql.php?rev=7253

        I think u need to let the default mysql float and double types be set if options are not specified explicitly for length/scale. This problem causes all doubles and floats to have poor 2 decimal precision.

        Show
        Hash added a comment - This change doesn't fix the problem. The problem here is that float and double types default to (18,2) for no good reason. See line 233: http://trac.doctrine-project.org/browser/branches/1.2/lib/Doctrine/DataDict/Mysql.php?rev=7253 I think u need to let the default mysql float and double types be set if options are not specified explicitly for length/scale. This problem causes all doubles and floats to have poor 2 decimal precision.
        Hide
        Jonathan H. Wage added a comment -

        Doctrine always sets the default if nothing is specified currently so we can't change that we can set our own length and scale though. However, I don't know what proper values would be. I'll do some tests and report back, let me know if you have any additional information. Thanks, Jon

        Show
        Jonathan H. Wage added a comment - Doctrine always sets the default if nothing is specified currently so we can't change that we can set our own length and scale though. However, I don't know what proper values would be. I'll do some tests and report back, let me know if you have any additional information. Thanks, Jon
        Hide
        Hash added a comment -

        Well it seems that Doctrine sets the default to 18,2 but afaik that is not necessary. I would suggest that if no scale is specified then the data type is simply defined as FLOAT or DOUBLE with no scale. This works fine for Mysql in my project.

        Show
        Hash added a comment - Well it seems that Doctrine sets the default to 18,2 but afaik that is not necessary. I would suggest that if no scale is specified then the data type is simply defined as FLOAT or DOUBLE with no scale. This works fine for Mysql in my project.
        Hide
        Severin Puschkarski added a comment -

        On Symfony 1.4.8 / Mysql it is still not working
        Setting to
        type: float(18), scale: 6
        enhances precission, but the numbers are rounded weirdly in the database:
        for example 76.86 is stored as 76.860001
        I really would appreciate a true mysql float!!!

        Show
        Severin Puschkarski added a comment - On Symfony 1.4.8 / Mysql it is still not working Setting to type: float(18), scale: 6 enhances precission, but the numbers are rounded weirdly in the database: for example 76.86 is stored as 76.860001 I really would appreciate a true mysql float!!!
        Hide
        Malcolm Hall added a comment -

        Still broken on 1.2.4 the last release of 1.2 unfortunately. This is the fix I used:

        Change line 239 of lib/Doctrine/DataDict/Mysql.php from:

        return 'DOUBLE('.$length.', '.$scale.')';

        to

        return 'DOUBLE';

        This gets rid of scale completely but I think its better than all doubles that don't have a defined scale limited to decimal places, which is just awful for anyone using the Geographical behaviour.

        Show
        Malcolm Hall added a comment - Still broken on 1.2.4 the last release of 1.2 unfortunately. This is the fix I used: Change line 239 of lib/Doctrine/DataDict/Mysql.php from: return 'DOUBLE('.$length.', '.$scale.')'; to return 'DOUBLE'; This gets rid of scale completely but I think its better than all doubles that don't have a defined scale limited to decimal places, which is just awful for anyone using the Geographical behaviour.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Dominik.Roser
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: