Summary: | Incorrect export to SQL | ||
---|---|---|---|
Product: | [Applications] umbrello | Reporter: | Alexey Parshin <alexeyp> |
Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch to fix sql export |
Description
Alexey Parshin
2006-11-30 10:53:32 UTC
Created attachment 18732 [details]
Patch to fix sql export
> Patch to fix sql export
The attachment contains the diff for sqlwriter.cpp but
apparently you have added a new member, constraintMap.
Please check - did you also modify sqlwriter.h (or some
other file?)
Sorry, forget about Comment #2. All is fine and I will apply instantly. SVN commit 609424 by okellogg: Apply attachment 18732 [details] from Alexey Parshin with slight modification. writeClass(): Add an auxiliary variable, constraintMap, to avoid excessive code for duplicated associations. (Those duplicated associations should not be there in the first place though.) writeAttributes(): Generate code for implementation-level attributes. BUG:138139 M +1 -0 ChangeLog M +24 -11 umbrello/codegenerators/sqlwriter.cpp --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #609423:609424 @@ -11,6 +11,7 @@ http://www.geeksoc.org/~jr/umbrello/uml-devel/9863.html * Bugs/wishes from http://bugs.kde.org: * Artifacts of a component diagram are wrongly placed in Deployment View folder (137564) +* Incorrect export to SQL (138139) Version 1.5.52 --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/sqlwriter.cpp #609423:609424 @@ -83,6 +83,9 @@ if (isClass) writeAttributes(c, sql); + sql << m_endl << ");" << m_endl; + + QMap<UMLAssociation*,UMLAssociation*> constraintMap; // so we don't repeat constraint UMLAssociationList aggregations = c->getAggregations(); if( forceSections() || !aggregations.isEmpty() ) { for(UMLAssociation* a = aggregations.first(); a; a = aggregations.next()) { @@ -90,18 +93,20 @@ 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 << ")"; + constraintMap[a] = a; } } + + QMap<UMLAssociation*,UMLAssociation*>::Iterator itor = constraintMap.begin(); + for (;itor != constraintMap.end();itor++) { + UMLAssociation* a = itor.data(); + sql << "ALTER TABLE "<< classname + << " ADD CONSTRAINT " << a->getName() << " FOREIGN KEY (" + << a->getRoleName(Uml::B) << ") REFERENCES " + << a->getObject(Uml::A)->getName() + << " (" << a->getRoleName(Uml::A) << ");" << m_endl; + } - sql << m_endl << ");" << m_endl; file.close(); emit codeGenerated(c, true); @@ -109,10 +114,11 @@ void SQLWriter::writeAttributes(UMLClassifier *c, QTextStream &sql) { - UMLAttributeList atpub, atprot, atpriv; + UMLAttributeList atpub, atprot, atpriv, atimp; atpub.setAutoDelete(false); atprot.setAutoDelete(false); atpriv.setAutoDelete(false); + atimp.setAutoDelete(false); //sort attributes by scope and see if they have a default value UMLAttributeList atl = c->getAttributeList(); @@ -127,7 +133,8 @@ case Uml::Visibility::Private: atpriv.append(at); break; - default: + case Uml::Visibility::Implementation: + atimp.append(at); break; } } @@ -155,6 +162,12 @@ first = false; } + if (atimp.count() > 0) + { + printAttributes(sql, atimp, first); + first = false; + } + return; } |