Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      When I run doctrine:migrations:diff on an MSSQL database, I get a load of pointless statements everytime - i.e VARCHAR(MAX) NULL

      $this->addSql("ALTER TABLE attachment ALTER COLUMN dec_generic_field VARCHAR(MAX) NULL");
      $this->addSql("ALTER TABLE attachment ALTER COLUMN dec_custom_field VARCHAR(MAX) NULL");
      $this->addSql("ALTER TABLE category ALTER COLUMN dec_generic_field VARCHAR(MAX) NULL");
      $this->addSql("ALTER TABLE category ALTER COLUMN dec_custom_field VARCHAR(MAX) NULL");

      Is this a bug?

      P.s this doesn't happen on our MySQL db

      ---------------

      according to stof:

      Then it means it is not an issue in the migrations library but in the DBAL schema comparator

        Issue Links

          Activity

          Hide
          Christophe Coevoet added a comment -

          Can you paste your ORM mapping for these columns ?

          Show
          Christophe Coevoet added a comment - Can you paste your ORM mapping for these columns ?
          Hide
          Steven Masala added a comment - - edited

          @ORM\Column(name="dec_generic_field", type="object", nullable=true)
          @ORM\Column(name="dec_custom_field", type="object", nullable=true)

          Show
          Steven Masala added a comment - - edited @ORM\Column(name="dec_generic_field", type="object", nullable=true) @ORM\Column(name="dec_custom_field", type="object", nullable=true)
          Hide
          Christophe Coevoet added a comment -

          This is happening because the primary mapping of a database VARCHAR field is the Doctrine StringType. But the doctrine ObjectType also uses a VARCHAR for its storage in the database.
          On platforms supporting column comments, Doctrine puts a special comment to identify the doctrine type associated to the field, so that the schema tool can identify it properly when comparing the DB schema to the ORM schema.

          the difference in your case is that MySQL supports inline column comments while the SqlServer platform does not.

          Show
          Christophe Coevoet added a comment - This is happening because the primary mapping of a database VARCHAR field is the Doctrine StringType. But the doctrine ObjectType also uses a VARCHAR for its storage in the database. On platforms supporting column comments, Doctrine puts a special comment to identify the doctrine type associated to the field, so that the schema tool can identify it properly when comparing the DB schema to the ORM schema. the difference in your case is that MySQL supports inline column comments while the SqlServer platform does not.
          Hide
          Steven Masala added a comment -

          and how can change that? so that every time we call migrations:diff those statements for each table is no longer unnecessary created.

          Show
          Steven Masala added a comment - and how can change that? so that every time we call migrations:diff those statements for each table is no longer unnecessary created.
          Hide
          Steve Müller added a comment -

          There is another issue that referes to the exact same issue.

          Show
          Steve Müller added a comment - There is another issue that referes to the exact same issue.
          Hide
          Steve Müller added a comment -

          A WIP PR is opended to support SQL Server comments:

          https://github.com/doctrine/dbal/pull/426

          Show
          Steve Müller added a comment - A WIP PR is opended to support SQL Server comments: https://github.com/doctrine/dbal/pull/426
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-426] was closed:
          https://github.com/doctrine/dbal/pull/426

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-426] was closed: https://github.com/doctrine/dbal/pull/426
          Show
          Steve Müller added a comment - - edited Fixed in commit: https://github.com/doctrine/dbal/commit/28264a15a404496155d84a0abfa3404d01302905

            People

            • Assignee:
              Steve Müller
              Reporter:
              Steven Masala
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: