Author: doogie
Date: Mon Aug 2 17:42:39 2010 New Revision: 981624 URL: http://svn.apache.org/viewvc?rev=981624&view=rev Log: No longer use ON in relation settings; instead, use MAP, which makes the sql a little bit simpler. Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj?rev=981624&r1=981623&r2=981624&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Mon Aug 2 17:42:39 2010 @@ -133,6 +133,7 @@ TOKEN: { | <IS: "IS"> | <NOT: "NOT"> | <NULL: "NULL"> + | <MAP: "MAP"> | <START_DQUOTE: "\""> { pushState(IN_DQUOTE); } | <START_SQUOTE: "'"> { pushState(IN_SQUOTE); } | <INTEGER: @@ -309,12 +310,16 @@ private SQLSelect Select(): { private void Relation(Map<String, Relation> relations): { String type = null, title = null, entityName; - List<KeyMap> keyMaps; + KeyMap keyMap; + List<KeyMap> keyMaps = FastList.newInstance(); } { ( <TYPE> type=NamePart() )? ( <TITLE> title=NamePart() )? <NAME> { entityName = getToken(0).image; } - keyMaps=KeyMaps("cur", "other") + <MAP> keyMap=PlainKeyMap() { keyMaps.add(keyMap); } ( + <COMMA> + keyMap=PlainKeyMap() { keyMaps.add(keyMap); } + )* { Relation relation = new Relation(type, title, entityName, keyMaps); if (relations.containsKey(relation.getName())) throw new ParseException("Duplicate relation: " + relation); @@ -322,6 +327,15 @@ private void Relation(Map<String, Relati } } +private KeyMap PlainKeyMap(): { + String left, right; +} { + left=NamePart() ( + <EQUALS> right=NamePart() { return new KeyMap(left, right); } + | { return new KeyMap(left, left); } + ) +} + private SQLUpdate Update(): { TableName tableName; List<Table> tableList = null; Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java?rev=981624&r1=981623&r2=981624&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java Mon Aug 2 17:42:39 2010 @@ -74,12 +74,12 @@ public final class Relation extends Atom sb.append(" TITLE ").append(title); } sb.append(' ').append(entityName); - sb.append(" ON"); + sb.append(" MAP"); for (int i = 0; i < keyMaps.size(); i++) { KeyMap keyMap = keyMaps.get(i); if (i != 0) sb.append(" AND "); - sb.append(" cur.").append(keyMap.getLeftFieldName()); - sb.append(" = other.").append(keyMap.getRightFieldName()); + sb.append(' ').append(keyMap.getLeftFieldName()); + sb.append(" = ").append(keyMap.getRightFieldName()); } return sb; } Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql?rev=981624&r1=981623&r2=981624&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/GoodParseAll.sql Mon Aug 2 17:42:39 2010 @@ -33,10 +33,10 @@ FROM Party a LEFT JOIN Person b USING partyId LEFT JOIN PartyGroup c ON b.partyId = c.partyId JOIN PartyRole d ON c.partyId = d.partyId AND c.partyId = d.partyId -RELATION TYPE one TITLE MainA Person USING partyId -RELATION TITLE MainB Person USING partyId -RELATION TYPE one Person USING partyId -RELATION PartyGroup USING partyId +RELATION TYPE one TITLE MainA Person MAP partyId +RELATION TITLE MainB Person MAP partyId +RELATION TYPE one Person MAP partyId +RELATION PartyGroup MAP partyId WHERE a.partyTypeId = 'PERSON' AND |
Free forum by Nabble | Edit this page |