DBDoc and PendingSQLWriter

I spent some time today investigating DBDoc and ran into an issue with its view for Pending SQL changes.

The 1.9.5 release does not show the SQL that needs to be run. After some investigation, it looks like PendingSQLWriter extends HTMLWriter and overrides writeBody. However, it looks like HTMLWriter’s signature for writeBody changed and PendingSQLWriter was never updated:

HTMLWriter:

    protected void writeBody(FileWriter fileWriter, Object object, List ranChanges, List changesToRun) throws IOException{

PendingSQLWriter:

    protected void writeBody(FileWriter fileWriter, Object object, List ranChanges, List changesToRun, Liquibase liquibase) throws IOException{

I tried updating PendingSQLWriter to use the new method signature and rebuilt 1.9.5 from source with the following change:

Old PendingSQLWriter:

        protected void writeBody(FileWriter fileWriter, Object object, List ranChanges, List changesToRun, Liquibase liquibase) throws IOException{         if (changesToRun.size() == 0) {             fileWriter.append("NONE");         }

            fileWriter.append("

    ");

            ChangeSet lastRunChangeSet = null;

            for (Change change : changesToRun) {
                ChangeSet thisChangeSet = change.getChangeSet();
                if (thisChangeSet.equals(lastRunChangeSet)) {
                    continue;
                }
                lastRunChangeSet = thisChangeSet;
                String anchor = thisChangeSet.toString(false).replaceAll("\W","_");
                fileWriter.append("");
                try {
                    thisChangeSet.execute(liquibase.getDatabase());
                } catch (MigrationFailedException e) {
                    fileWriter.append(“EXECUTION ERROR: “).append(change.getChangeName()).append(”: “).append(e.getMessage()).append(”\n\n”);
                }
            }
            fileWriter.append("

    ");
        }

New PendingSQLWriter:

        protected void writeBody(FileWriter fileWriter, Object object, List ranChanges, List changesToRun) throws IOException{         if (changesToRun.size() == 0) {             fileWriter.append("NONE");         }

            fileWriter.append("

    ");

            ChangeSet lastRunChangeSet = null;

            for (Change change : changesToRun) {
                ChangeSet thisChangeSet = change.getChangeSet();
                if (thisChangeSet.equals(lastRunChangeSet)) {
                    continue;
                }
                lastRunChangeSet = thisChangeSet;
                String anchor = thisChangeSet.toString(false).replaceAll("\W","_");
                fileWriter.append("
    ");
                try {
                    thisChangeSet.execute(database);
                } catch (MigrationFailedException e) {
                    fileWriter.append(“EXECUTION ERROR: “).append(change.getChangeName()).append(”: “).append(e.getMessage()).append(”\n\n”);
                }
            }
            fileWriter.append("

    ");
        }

However, the line that (as far as I can tell) is supposed to print the SQL to html is actually executing the SQL instead:

    thisChangeSet.execute(database);

I haven’t tried running the same fix on trunk, but the PendingSQLWriter/HTMLWriter writeBody method signatures seem to be different there as well.

Does anybody have any ideas on what I can do to get 1.9.5 (or trunk, if necessary) to generate DBDoc with a functioning “Pending SQL Changes”?

Thanks!

Sorry for the slow reply.  I created an issue for this http://liquibase.jira.com/browse/CORE-615 to be fixed for the next 2.0 RC.

Nathan