db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Hyzer (JIRA)" <j...@apache.org>
Subject [jira] Created: (DDLUTILS-220) if you drop a column, and it is not the last column, a column order change is detected in error
Date Tue, 29 Jul 2008 17:53:32 GMT
if you drop a column, and it is not the last column, a column order change is detected in error
-----------------------------------------------------------------------------------------------

                 Key: DDLUTILS-220
                 URL: https://issues.apache.org/jira/browse/DDLUTILS-220
             Project: DdlUtils
          Issue Type: Improvement
          Components: Core (No specific database)
    Affects Versions: 1.0
            Reporter: Chris Hyzer
            Assignee: Thomas Dudziak


I can work on the code for this if someone can spend a little time discussing...

I am using oracle, but it may affect other DBs...

Does this have to work this way?  When I drop a column (and its not at the end of the list),
a column or change is detected, and the resulting script is to create a new table, copy data
over, and recreate the table, and copy table back.  This might not seem undesirable, but if
I have a unique constraint (which ddlutils doesnt support) it is effectively dropped (same
with column or table comments which ddlutils doesnt support.  Anyways, I think this algorithm
could be spruced up to detect if a column is recordered, or if a column is just dropped...

>From ModelComparator:

        HashMap columnPosChanges = new HashMap();

        for (int columnIdx = 0; columnIdx < sourceTable.getColumnCount(); columnIdx++)
        {
            Column sourceColumn = sourceTable.getColumn(columnIdx);
            Column targetColumn = targetTable.findColumn(sourceColumn.getName(), _caseSensitive);

            if (targetColumn == null)
            {
                if (_log.isInfoEnabled())
                {
                    _log.info("Column " + sourceColumn.getName() + " needs to be removed from
table " + sourceTable.getName());
                }
                changes.add(new RemoveColumnChange(sourceTable, sourceColumn));
            }
            else
            {
                int targetColumnIdx = targetTable.getColumnIndex(targetColumn);

                if (targetColumnIdx != columnIdx)
                {
                    columnPosChanges.put(sourceColumn, new Integer(targetColumnIdx));
                }
            }
        }
        if (!columnPosChanges.isEmpty())
        {
            changes.add(new ColumnOrderChange(sourceTable, columnPosChanges));
        }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message