Doctrine 1
  1. Doctrine 1
  2. DC-314

length option ignored in addColumn method in Doctrine 1.2 migrations

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.2.1
    • Component/s: Migrations
    • Labels:
      None
    • Environment:
      Symfony 1.3

      Description

      I am using http://doctrine.mirror.svn.symfony-project.com/branches/1.2/lib and saw this problem with revision 6806.

      The 'length' parameter in the options array seems to be
      ignored by addColumn in Doctrine 1.2 migrations. No matter what we specified for
      'length' we got a bigint in MySQL, resulting in failure later when we
      tried to add a foreign key because we needed a 4-byte integer. There
      does not seem to be any documentation of what is valid in the options
      array when calling addColumn, however I see that length is still used
      when passing an apparently identical options array for a particular
      column when calling createTable.

      That is, this code:

      $this->addColumn('pg_event_request', 'event_id', 'integer',
      array('length' => 4));

      Does not work properly in Doctrine 1.2 (you get a bigint in MySQL).

      We were able to work around it by implementing a migrate() method
      instead, passing 4 as the final argument (there doesn't seem to be
      clear documentation of this final argument but in the example in the
      documentation it is the length of a string column, and sure enough it
      does the same thing for an integer). Passing 4 here worked, we got a
      4-byte integer.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I just fixed this here hehe

        http://trac.doctrine-project.org/changeset/6842

        Also, the function signature in 1.2 is:

            public function addColumn($tableName, $columnName, $type, $length = null, array $options = array())
        

        It has the $length argument, but you can still pass the length via the options. In the end all that information is just in one array.

        Show
        Jonathan H. Wage added a comment - I just fixed this here hehe http://trac.doctrine-project.org/changeset/6842 Also, the function signature in 1.2 is: public function addColumn($tableName, $columnName, $type, $length = null , array $options = array()) It has the $length argument, but you can still pass the length via the options. In the end all that information is just in one array.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: