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

SqlBuilder does not shorten the name of columns in references in foreignkeys

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.0
    • None
    • None
    • Tested with Postgresql

    Description

      Sqlbuilder shortens the names of columns and tables corresponding to the length found in PlatformInfo. When writing the column names in the References of the ForeignKeys this shortening is not applied. This leads to invalid foreignkeys when your column name was longer than the max size.

      I have applied a fix locally in the source. This is what I changed in SqlBuilder class:

      protected void writeForeignReferences(ForeignKey key) throws IOException
      {
      for (int idx = 0; idx < key.getReferenceCount(); idx++)
      {
      if (idx > 0)

      { print(", "); }
      // FIXME added this myself to prevent foreign keys references having too long columnname lenght
      printIdentifier(shortenName(key.getReference(idx).getForeignColumnName(),getMaxColumnNameLength()));
      }
      }

      /**
      * Writes a list of local references for the given foreign key.
      *
      * @param key The foreign key
      */
      protected void writeLocalReferences(ForeignKey key) throws IOException
      {
      for (int idx = 0; idx < key.getReferenceCount(); idx++)
      {
      if (idx > 0)
      { print(", "); }

      // FIXME same
      printIdentifier(shortenName(key.getReference(idx).getLocalColumnName(), getMaxColumnNameLength()));
      }
      }

      Attachments

        Issue Links

          Activity

            People

              tomdz Thomas Dudziak
              omen Damien Trog
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 5m
                  5m
                  Remaining:
                  Remaining Estimate - 5m
                  5m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified