Author: thomasobrien95
Date: Mon Dec  8 13:05:16 2008
New Revision: 2868

Modified:
   trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
   trunk/src/ca/sqlpower/architect/ddl/MySqlDDLGenerator.java
   trunk/src/ca/sqlpower/architect/ddl/OracleDDLGenerator.java
   trunk/src/ca/sqlpower/architect/ddl/PostgresDDLGenerator.java
   trunk/src/ca/sqlpower/architect/ddl/SQLServerDDLGenerator.java

Log:
This is a fix for bug 1168. The SQL Script generated by the DDL generators were inconsistent in their format. Now the generated SQL is left aligned in the same fashion and double spaced throughout the script.

Modified: trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java        
(original)
+++ trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Mon Dec 8 13:05:16 2008
@@ -291,7 +291,7 @@

        public void dropRelationship(SQLRelationship r) {

-               print("\n ALTER TABLE ");
+               print("\nALTER TABLE ");

                print( toQualifiedName(r.getFkTable()) );
                print(" DROP CONSTRAINT ");
@@ -446,10 +446,10 @@
                    } else {
                        errorMsg.append("*/");
                    }
-                   sql.insert(0, "/*\n" + errorMsg.toString());
+                   sql.insert(0, "\n/*\n" + errorMsg.toString());
                }
                
-        print("\n" + sql.toString());
+        print(sql.toString());

                endStatement(DDLStatement.StatementType.CREATE, r);

@@ -567,7 +567,7 @@

        public void addColumn(SQLColumn c) {
                Map colNameMap = new HashMap();
-               print("\n ALTER TABLE ");
+               print("\nALTER TABLE ");
                print(toQualifiedName(c.getParentTable()));
                print(" ADD COLUMN ");
                print(columnDefinition(c,colNameMap));
@@ -577,7 +577,7 @@

        public void dropColumn(SQLColumn c) {
                Map colNameMap = new HashMap();
-               print("\n ALTER TABLE ");
+               print("\nALTER TABLE ");
                print(toQualifiedName(c.getParentTable()));
                print(" DROP COLUMN ");
                print(createPhysicalName(colNameMap,c));
@@ -588,7 +588,7 @@
        public void modifyColumn(SQLColumn c) {
                Map colNameMap = new HashMap();
                SQLTable t = c.getParentTable();
-               print("\n ALTER TABLE ");
+               print("\nALTER TABLE ");
                print(toQualifiedName(t));
                print(" ALTER COLUMN ");
                print(columnDefinition(c,colNameMap));
@@ -1195,7 +1195,7 @@
* Generates a standard <code>DROP TABLE $tablename</code> command. Should work on most platforms.
      */
     public String makeDropTableSQL(String table) {
-        return "DROP TABLE "+toQualifiedName(table);
+        return "\nDROP TABLE "+toQualifiedName(table);
     }

     /**
@@ -1203,7 +1203,7 @@
* The statement looks like <code>ALTER TABLE $fktable DROP FOREIGN KEY $fkname</code>.
      */
     public String makeDropForeignKeySQL(String fkTable, String fkName) {
-        return "ALTER TABLE "
+        return "\nALTER TABLE "
             +toQualifiedName(fkTable)
             +" DROP FOREIGN KEY "
             +fkName;
@@ -1216,7 +1216,7 @@
        public void dropPrimaryKey(SQLTable t) {

                try {
-            print("ALTER TABLE " + toQualifiedName(t.getName())
+            print("\nALTER TABLE " + toQualifiedName(t.getName())
                + " DROP PRIMARY KEY " + t.getPrimaryKeyName());
         } catch (ArchitectException e) {
             throw new ArchitectRuntimeException(e);
@@ -1228,7 +1228,7 @@
                Map colNameMap = new HashMap();
                StringBuffer sqlStatement = new StringBuffer();
                boolean first = true;
-               sqlStatement.append("ALTER TABLE "+ toQualifiedName(t.getName())
+               sqlStatement.append("\nALTER TABLE "+ 
toQualifiedName(t.getName())
                                + " ADD PRIMARY KEY (");
                for (SQLColumn c : t.getColumns()) {
                        if (c.isPrimaryKey()) {

Modified: trunk/src/ca/sqlpower/architect/ddl/MySqlDDLGenerator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ddl/MySqlDDLGenerator.java  (original)
+++ trunk/src/ca/sqlpower/architect/ddl/MySqlDDLGenerator.java Mon Dec 8 13:05:16 2008
@@ -388,7 +388,7 @@

     public void dropRelationship(SQLRelationship r) {

-        print("\n ALTER TABLE ");
+        print("\nALTER TABLE ");

         print(toQualifiedName(r.getFkTable()));
         print(" DROP FOREIGN KEY ");
@@ -527,7 +527,7 @@
     public void modifyColumn(SQLColumn c) {
         Map colNameMap = new HashMap();
         SQLTable t = c.getParentTable();
-        print("\n ALTER TABLE ");
+        print("\nALTER TABLE ");
         print(toQualifiedName(t));
         print(" MODIFY COLUMN ");
         print(columnDefinition(c, colNameMap));

Modified: trunk/src/ca/sqlpower/architect/ddl/OracleDDLGenerator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ddl/OracleDDLGenerator.java (original)
+++ trunk/src/ca/sqlpower/architect/ddl/OracleDDLGenerator.java Mon Dec 8 13:05:16 2008
@@ -303,7 +303,7 @@
      */
     @Override
     public String makeDropForeignKeySQL(String fkTable, String fkName) {
-        return "ALTER TABLE "
+        return "\nALTER TABLE "
             + toQualifiedName(fkTable)
             + " DROP CONSTRAINT "
             + fkName;
@@ -318,7 +318,7 @@
     public void modifyColumn(SQLColumn c) {
                Map colNameMap = new HashMap();
                SQLTable t = c.getParentTable();
-               print("\n ALTER TABLE ");
+               print("\nALTER TABLE ");
                print(toQualifiedName(t.getPhysicalName()));
                print(" MODIFY ");
                print(columnDefinition(c,colNameMap));
@@ -332,7 +332,7 @@
     @Override
     public void addColumn(SQLColumn c) {
         Map colNameMap = new HashMap();
-        print("\n ALTER TABLE ");
+        print("\nALTER TABLE ");
         print(toQualifiedName(c.getParentTable()));
         print(" ADD ");
         print(columnDefinition(c,colNameMap));
@@ -385,7 +385,7 @@
         for (SQLColumn c : t.getColumns()) {
             if (c.isAutoIncrement()) {
SQLSequence seq = new SQLSequence(toIdentifier(c.getAutoIncrementSequenceName()));
-                print("CREATE SEQUENCE ");
+                print("\nCREATE SEQUENCE ");
                 print(createSeqPhysicalName(topLevelNames, seq, c));
                 endStatement(StatementType.CREATE, seq);
             }

Modified: trunk/src/ca/sqlpower/architect/ddl/PostgresDDLGenerator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ddl/PostgresDDLGenerator.java       
(original)
+++ trunk/src/ca/sqlpower/architect/ddl/PostgresDDLGenerator.java Mon Dec 8 13:05:16 2008
@@ -264,7 +264,7 @@
      */
     @Override
     public String makeDropForeignKeySQL(String fkTable, String fkName) {
-        return "\n ALTER TABLE ONLY "
+        return "\nALTER TABLE ONLY "
             + toQualifiedName(fkTable)
             + " DROP CONSTRAINT "
             + fkName;
@@ -274,7 +274,7 @@
     public void modifyColumn(SQLColumn c) {
         Map colNameMap = new HashMap();
         SQLTable t = c.getParentTable();
-        print("\n ALTER TABLE ONLY ");
+        print("\nALTER TABLE ONLY ");
         print( toQualifiedName(t) );
         print(" ALTER COLUMN ");

@@ -378,7 +378,7 @@
         for (SQLColumn c : t.getColumns()) {
             if (c.isAutoIncrement()) {
SQLSequence seq = new SQLSequence(toIdentifier(c.getAutoIncrementSequenceName()));
-                print("CREATE SEQUENCE ");
+                print("\nCREATE SEQUENCE ");
print(toQualifiedName(createSeqPhysicalName(topLevelNames, seq, c)));
                 endStatement(StatementType.CREATE, seq);
             }
@@ -390,7 +390,7 @@
         for (SQLColumn c : t.getColumns()) {
             if (c.isAutoIncrement()) {
SQLSequence seq = new SQLSequence(toIdentifier(c.getAutoIncrementSequenceName())); - print("ALTER SEQUENCE " + toQualifiedName(seq.getName()) + " OWNED BY " + toQualifiedName(t) + "." + c.getPhysicalName()); + print("\nALTER SEQUENCE " + toQualifiedName(seq.getName()) + " OWNED BY " + toQualifiedName(t) + "." + c.getPhysicalName());
                 endStatement(StatementType.CREATE, seq);
             }
         }

Modified: trunk/src/ca/sqlpower/architect/ddl/SQLServerDDLGenerator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ddl/SQLServerDDLGenerator.java (original) +++ trunk/src/ca/sqlpower/architect/ddl/SQLServerDDLGenerator.java Mon Dec 8 13:05:16 2008
@@ -387,7 +387,7 @@

     @Override
     public void addColumn(SQLColumn c) {
-        print("\n ALTER TABLE ");
+        print("\nALTER TABLE ");
         print(toQualifiedName(c.getParentTable()));
         print(" ADD ");
         print(columnDefinition(c,new HashMap()));
@@ -457,7 +457,7 @@
     @Override
     public void dropPrimaryKey(SQLTable t) {
         try {
-            print("ALTER TABLE " + toQualifiedName(t.getName())
+            print("\nALTER TABLE " + toQualifiedName(t.getName())
                 + " DROP " + t.getPrimaryKeyName());
         } catch (ArchitectException e) {
             throw new ArchitectRuntimeException(e);
@@ -467,7 +467,7 @@

     @Override
     public String makeDropForeignKeySQL(String fkTable, String fkName) {
-        return "ALTER TABLE "
+        return "\nALTER TABLE "
         +toQualifiedName(fkTable)
         +" DROP CONSTRAINT "
         +fkName;

Reply via email to