You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2017/02/20 09:54:45 UTC

cayenne git commit: CAY-2236 Modeler Migrate DB Schema: unable to Reverse All Operations

Repository: cayenne
Updated Branches:
  refs/heads/master eb7945468 -> 103a2026f


CAY-2236 Modeler Migrate DB Schema: unable to Reverse All Operations


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/103a2026
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/103a2026
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/103a2026

Branch: refs/heads/master
Commit: 103a2026fb867528bc1e252b4281fd28ab744479
Parents: eb79454
Author: Nikita Timofeev <st...@gmail.com>
Authored: Mon Feb 20 12:54:40 2017 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Mon Feb 20 12:54:40 2017 +0300

----------------------------------------------------------------------
 .../token/model/AddRelationshipToModel.java      | 19 ++++++-------------
 docs/doc/src/main/resources/RELEASE-NOTES.txt    |  1 +
 2 files changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/103a2026/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/model/AddRelationshipToModel.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/model/AddRelationshipToModel.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/model/AddRelationshipToModel.java
index 659e286..8647485 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/model/AddRelationshipToModel.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/model/AddRelationshipToModel.java
@@ -48,7 +48,11 @@ public class AddRelationshipToModel extends AbstractToModelToken.Entity {
                 attributes += dbJoin.getTargetName() + COMMA_SEPARATOR;
             }
 
-            attributes = "{" + attributes.substring(0, attributes.length() - COMMA_SEPARATOR_LENGTH) + "}";
+            if(attributes.isEmpty()) {
+                attributes = "{}";
+            } else {
+                attributes = "{" + attributes.substring(0, attributes.length() - COMMA_SEPARATOR_LENGTH) + "}";
+            }
         }
 
         return rel.getName() + " " + rel.getSourceEntity().getName() + "->" + rel.getTargetEntityName() + "." + attributes;
@@ -76,17 +80,6 @@ public class AddRelationshipToModel extends AbstractToModelToken.Entity {
 
     @Override
     public String getTokenValue() {
-        String attributes = "";
-        if (relationship.getJoins().size() == 1) {
-            attributes = relationship.getJoins().get(0).getTargetName();
-        } else {
-            for (DbJoin dbJoin : relationship.getJoins()) {
-                attributes += dbJoin.getTargetName() + COMMA_SEPARATOR;
-            }
-
-            attributes = "{" + attributes.substring(0, attributes.length() - COMMA_SEPARATOR_LENGTH) + "}";
-        }
-
-        return relationship.getName() + " " + relationship.getSourceEntity().getName() + "->" + relationship.getTargetEntityName() + "." + attributes;
+        return getTokenValue(relationship);
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/103a2026/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 7a1cdf7..1562ac5 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -44,6 +44,7 @@ CAY-2175 AliasName used in EJBQLQuery is not working if it contains mixed case
 CAY-2183 Newly created DbRelationship is unexpectedly renamed by the Modeler
 CAY-2199 Modeler on Windows: The same project is displayed twice in "Recent Projects"
 CAY-2221 In-memory expression evaluation gives different result than select query
+CAY-2236 Modeler Migrate DB Schema: unable to Reverse All Operations
 
 ----------------------------------
 Release: 4.0.M4