[Uml-devel] KDE/kdesdk/umbrello/umbrello/codegenerators/sql

Andi Fischer andi.fischer at hispeed.ch
Wed Aug 6 10:32:52 UTC 2008


SVN commit 842976 by fischer:

Removing too many endl between attributes and second attribute comment.

 M  +4 -6      mysqlwriter.cpp  
 M  +1 -1      mysqlwriter.h  
 M  +7 -15     sqlwriter.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/sql/mysqlwriter.cpp #842975:842976
@@ -74,7 +74,6 @@
     return l;
 }
 
-
 void MySQLWriter::printForeignKeyConstraints(QTextStream& sql, UMLClassifierListItemList constrList)
 {
     // we need to create an index on the referenced attributes before we can create a foreign key constraint in MySQL
@@ -95,21 +94,20 @@
 
         // create an index on them
         SQLWriter::printIndex( sql, fkc->getReferencedEntity(), refAttList );
-
     }
 
     SQLWriter::printForeignKeyConstraints( sql, constrList );
 }
 
-void MySQLWriter::printAutoIncrements(QTextStream& sql, UMLEntityAttributeList entAttList)
+void MySQLWriter::printAutoIncrements(QTextStream& sql, const UMLEntityAttributeList entAttList)
 {
     // rules
     // only one attribute can have an auto increment in a table in MySQL
     // and that attribute should have an index on it :/
 
     // get the first attribute of list with auto increment
-    UMLEntityAttribute* ea,  *autoIncrementEntAtt = NULL;
-    foreach( ea, entAttList ) {
+    UMLEntityAttribute* autoIncrementEntAtt = NULL;
+    foreach(UMLEntityAttribute* ea, entAttList) {
        if ( ea->getAutoIncrement() ) {
            autoIncrementEntAtt = ea;
            break;
@@ -132,7 +130,7 @@
        <<" "<<cleanName( autoIncrementEntAtt->getName() )
        <<" "<<cleanName( autoIncrementEntAtt->getTypeName() )
        <<" "<<cleanName( autoIncrementEntAtt->getAttributes() )
-       <<" "<<" NOT NULL AUTO_INCREMENT ; ";
+       <<" "<<" NOT NULL AUTO_INCREMENT ;";
 
     sql<<m_endl;
 
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/sql/mysqlwriter.h #842975:842976
@@ -56,7 +56,7 @@
     /**
      * Reimplement printAutoIncrements from Base Class for MySQL
      */
-    void printAutoIncrements(QTextStream& sql, UMLEntityAttributeList entAttList);
+    void printAutoIncrements(QTextStream& sql, const UMLEntityAttributeList entAttList);
 
 };
 
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/sql/sqlwriter.cpp #842975:842976
@@ -90,7 +90,7 @@
     // write all entity attributes
     UMLEntityAttributeList entAttList = m_pEntity->getEntityAttributes();
 
-    sql << "CREATE TABLE "<< entityname << " ( " << m_endl;
+    sql << "CREATE TABLE "<< entityname << " (";
 
     printEntityAttributes(sql, entAttList);
 
@@ -346,10 +346,10 @@
 
     foreach ( UMLEntityAttribute* at, entityAttributeList ) {
        // print , after attribute
-         if (first == false) {
-             sql <<",";
-         } else {
+         if (first) {
              first = false;
+         } else {
+             sql <<",";
          }
 
         // print documentation/comment of last attribute at end of line
@@ -370,8 +370,9 @@
         bool ok;
         uint length = lengthStr.toUInt(&ok);
 
-        if ( ok )
+        if ( ok ) {
             sql<<'('<<length<<')';
+        }
 
         // write the attributes ( unsigned, zerofill etc)
         QString attributes = at->getAttributes().trimmed();
@@ -388,14 +389,6 @@
 
         // now get documentation/comment of current attribute
         attrDoc = at->getDoc();
-
-
-        // print documentation/comment at end of line
-        if (attrDoc.isEmpty() == false) {
-          sql << " -- " << attrDoc << m_endl;
-        } else {
-          sql << m_endl;
-        }
     }
 
     return;
@@ -404,10 +397,9 @@
 void SQLWriter::printUniqueConstraints(QTextStream& sql, UMLClassifierListItemList constrList)
 {
    foreach( UMLClassifierListItem* cli, constrList ) {
-
        sql<<m_endl;
-       UMLUniqueConstraint* uuc = static_cast<UMLUniqueConstraint*>(cli);
 
+       UMLUniqueConstraint* uuc = static_cast<UMLUniqueConstraint*>(cli);
        UMLEntityAttributeList attList = uuc->getEntityAttributeList();
 
        // print documentation




More information about the umbrello-devel mailing list