DdlUtils
  1. DdlUtils
  2. DDLUTILS-45

createDatabase and alterDatabase should give access to the generated SQL.

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0 RC1
    • Labels:
      None

      Description

      In a scenario where you work with XML-representations of databases, you do not necessarily want to first create the first schema in a database, and then alter to the second to see how it works.

      It would be quite suitable just to work on the models loaded from XML and then just generate the corresponding SQL without executing it.

      This would provide for debugging and documentation purposes.

      1. sql-access.txt
        6 kB
        Thorbjørn Ravn Andersen

        Activity

        Hide
        Thorbjørn Ravn Andersen added a comment -

        This functionality is what I extracted as methods from createDatabase and alterDatabase, so it basically exposes the underlying implementation. If this would be an officially supported functionality instead of just being possible, it would be nice to have public methods for doing this.

        Show
        Thorbjørn Ravn Andersen added a comment - This functionality is what I extracted as methods from createDatabase and alterDatabase, so it basically exposes the underlying implementation. If this would be an officially supported functionality instead of just being possible, it would be nice to have public methods for doing this.
        Hide
        Martin van den Bemt added a comment -

        This is already possible :

        Platform platform = PlatformFactory.createNewPlatformInstance(databaseType);
        StringWriter writer = new StringWriter();
        platform.getSqlBuilder().setWriter(writer);
        Database source = null;
        try

        { source = platform.getModelReader().getDatabase(getConnection()); }

        catch (SQLException e1)

        { e1.printStackTrace(); }

        try

        { platform.getSqlBuilder().alterDatabase(source, database, false, true); }

        catch (IOException e)

        { e.printStackTrace(); }

        System.out.println("sql : \n"+writer.getBuffer());

        Show
        Martin van den Bemt added a comment - This is already possible : Platform platform = PlatformFactory.createNewPlatformInstance(databaseType); StringWriter writer = new StringWriter(); platform.getSqlBuilder().setWriter(writer); Database source = null; try { source = platform.getModelReader().getDatabase(getConnection()); } catch (SQLException e1) { e1.printStackTrace(); } try { platform.getSqlBuilder().alterDatabase(source, database, false, true); } catch (IOException e) { e.printStackTrace(); } System.out.println("sql : \n"+writer.getBuffer());
        Hide
        Thorbjørn Ravn Andersen added a comment -

        Patch providing alterTablesSQL and createTablesSQL

        Show
        Thorbjørn Ravn Andersen added a comment - Patch providing alterTablesSQL and createTablesSQL

          People

          • Assignee:
            Thomas Dudziak
            Reporter:
            Thorbjørn Ravn Andersen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development