Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-833

[GH-542] [DBAL-825] Drop default constraints before altering column type on SQL Server

    Details

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

      Description

      This issue is created automatically through a Github pull request on behalf of deeky666:

      Url: https://github.com/doctrine/dbal/pull/542

      Message:

      SQL Server implements column default values as constraints and therefore requires them to be dropped before a column type change.
      This PR implements the recreation of default constraints on column type alterations.
      Additionally some code in `SQLServerPlatform::getAlterTableSQL()` has been refactored to avoid code duplication and unnecessary SQL generation.
      Please note that due to the issue's tests the PostgreSQL platform had to be altered to fulfill the same behaviour. PostgreSQL returned some strange default value like `666:smallint` when reverse engineering a column type change with a default value of `666` from type `smallint` to `integer`. So I think this PR fixes a bug in this platform, too. Additionally I had to change the deprecated default value retrieval SQL in PostgreSQL in order to work flawlessly. See the [documentation](http://www.postgresql.org/docs/9.3/static/catalog-pg-attrdef.html) at the very end.

      I would also like to note that this PR is definitely not the end of the line concerning default values and column alterations. Some weird errors were revealed on other platforms while fixing this issue. MySQL for example denies default values on BLOB/TEXT type columns, DB2 just throws non-understandable syntax errors around and Oracle seems to map decimal/numeric types without a defined scale to integer when reverse engineering (not really related to this issue but it came up while testing).

      Otherwise the tests pass on all platforms.

        Issue Links

          Activity

          Hide
          Doctrine Bot added a comment -

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

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-536] was closed: https://github.com/doctrine/dbal/pull/536
          Hide
          Doctrine Bot added a comment -

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

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

            People

            • Assignee:
              Steve Müller
              Reporter:
              Doctrine Bot
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: