[Uml-devel] [Bug 77377] SQL code generator generates "circular reference" foreign keys

Oliver Kellogg okellogg at users.sourceforge.net
Mon Nov 20 21:36:56 UTC 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=77377         




------- Additional Comments From okellogg users sourceforge net  2006-11-20 22:36 -------
SVN commit 606555 by okellogg:

Apply attachment 18621 by Alexey Parshin with slight modification.
Thanks Alexey for contributing.
CCBUG:77377


 M  +12 -8     sqlwriter.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/sqlwriter.cpp #606554:606555
 @ -86,14 +86,18  @
     UMLAssociationList aggregations = c->getAggregations();
     if( forceSections() || !aggregations.isEmpty() ) {
         for(UMLAssociation* a = aggregations.first(); a; a = aggregations.next()) {
-            if( a->getObject(Uml::A)->getID() != c->getID() ) {
-
-                sql << m_indentation << "," << m_endl << m_indentation
-                << "CONSTRAINT " << a->getName() << " FOREIGN KEY ("
-                << a->getRoleName(Uml::B) << ") REFERENCES "
-                << a->getObject(Uml::A)->getName()
-                << " (" << a->getRoleName(Uml::A) << ")";
-            }
+            UMLObject *objA = a->getObject(Uml::A);
+            UMLObject *objB = a->getObject(Uml::B);
+            if (objA->getID() == c->getID() && objB->getID() != c->getID())
+                continue;
+            QString roleNameA = a->getRoleName(Uml::A);
+            QString roleNameB = a->getRoleName(Uml::B);
+            if (roleNameA.isEmpty() || roleNameB.isEmpty())
+                continue;
+            sql << m_indentation << "," << m_endl;
+            sql << m_indentation << "CONSTRAINT " << a->getName()
+                << " FOREIGN KEY (" << roleNameB << ") REFERENCES "
+                << objA->getName() << " (" << roleNameA << ")";
         }
     }




More information about the umbrello-devel mailing list