Uploaded image for project: 'DdlUtils'
  1. DdlUtils
  2. DDLUTILS-235

Platform.alterTables detects way too many changes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.0
    • None
    • None

    Description

      When creating an ALTER-Script from two identical databases-Models obtained from an unchanged HSQLDB-Database (using the same database-model also does the trick), all SQLBuilders of all Platforms I've tried (including the HSQDB-Platform) generate SQL-Output, that creates temporary tables for each table, copies the content of the original tables into the temporary ones, drops the old tables, creates everything anew and copies the data back again recreating all constraints like they have been before.

      That is quite a lot of work for actually not changing anything.

      I've debugged a bit and found out, that the ModelComparator detects column-type changes by mapping the source-model's type via the platformspecific typemappings to the type of the target model (which remains unmapped).

      if (_platformInfo.getTargetJdbcType(targetColumn.getTypeCode()) != sourceColumn.getTypeCode())
      {
      changes.add(...);
      }

      This seems like a bug to me.

      Please correct me if I'm wrong, but I thought that a ddl-Database, as a model, does not include any specifications about the type or configuration of the database it has been extracted from. When comparing two databases for changes, the comparisions should then also be free of platform specific details. Those are only necessary when generating the SQL-Statements implementing the detected changes.

      I've patched the ModelComparator by changing the aforementioned line to

      if (targetColumn.getTypeCode() != sourceColumn.getTypeCode())
      {
      changes.add(...);
      }

      and now the Changedetection works like I would expect it to do (no changes on identical models, no unnecessary table- or contraint-drops).

      Attachments

        Activity

          People

            tomdz Thomas Dudziak
            bschmidt Björn Schmidt
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: