svn commit: r835792 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/sql/Parser.jj webslinger/websites/webslinger/www/TestSQL.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r835792 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/sql/Parser.jj webslinger/websites/webslinger/www/TestSQL.groovy

doogie-3
Author: doogie
Date: Fri Nov 13 09:47:58 2009
New Revision: 835792

URL: http://svn.apache.org/viewvc?rev=835792&view=rev
Log:
Add shorthand for keymap lists, making use of "USING".

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj
    ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj?rev=835792&r1=835791&r2=835792&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/Parser.jj Fri Nov 13 09:47:58 2009
@@ -78,6 +78,7 @@
 | <UNION: "UNION">
 | <BY: "BY">
 | <ON: "ON">
+| <USING: "USING">
 | <LIMIT: "LIMIT">
 | <OFFSET: "OFFSET">
 | <SELECT: "SELECT">
@@ -179,7 +180,7 @@
  ( LOOKAHEAD(2) <TYPE> type=NamePart() )?
  ( LOOKAHEAD(2) <TITLE> title=NamePart() )?
  entityName=NamePart()
- <ON> keyMaps=KeyMaps("cur", "other") {
+ keyMaps=KeyMaps("cur", "other") {
  System.err.println("addRelation(" + type + ", " + title + ", " + entityName + ", " + keyMaps + ")");
  dve.addRelation(type, title, entityName, keyMaps);
  }
@@ -216,7 +217,7 @@
  leftAlias=TableName(dve) { availableAliases.add(leftAlias); }
  (
  relOptional=Joiner() rightAlias=TableName(dve) { availableAliases.add(rightAlias); }
- <ON> keyMaps=KeyMaps(leftAlias, rightAlias) {
+ keyMaps=KeyMaps(leftAlias, rightAlias) {
      dve.addViewLink(leftAlias, rightAlias, relOptional, keyMaps);
  }
 
@@ -228,10 +229,18 @@
 {
  List<ModelKeyMap> keyMaps = FastList.newInstance();
  ModelKeyMap keyMap;
+ String n;
 }
 {
- keyMap=KeyMap(leftAlias, rightAlias) { keyMaps.add(keyMap); }
- ( <AND> keyMap=KeyMap(leftAlias, rightAlias) { keyMaps.add(keyMap); } )*
+ (
+ <ON>
+ keyMap=KeyMap(leftAlias, rightAlias) { keyMaps.add(keyMap); }
+ ( <AND> keyMap=KeyMap(leftAlias, rightAlias) { keyMaps.add(keyMap); } )*
+ |
+ <USING>
+ n=NamePart() { keyMaps.add(new ModelKeyMap(n, n)); }
+ ( <COMMA> n=NamePart() { keyMaps.add(new ModelKeyMap(n, n)); } )*
+ )
  { return keyMaps; }
 }
 

Modified: ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy?rev=835792&r1=835791&r2=835792&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy (original)
+++ ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy Fri Nov 13 09:47:58 2009
@@ -18,10 +18,10 @@
  b.lastName,
     c.groupName
 FROM
- Party a LEFT JOIN Person b ON a.partyId = b.partyId LEFT JOIN PartyGroup c on a.partyId = c.partyId
-RELATION TYPE one Party ON cur.partyId = other.partyId
-RELATION TYPE one Person ON cur.partyId = other.partyId
-RELATION TYPE one PartyGroup ON cur.partyId = other.partyId
+ Party a LEFT JOIN Person b USING partyId LEFT JOIN PartyGroup c USING partyId
+RELATION TYPE one Party USING partyId
+RELATION TYPE one Person USING partyId
+RELATION TYPE one PartyGroup USING partyId
 WHERE
     partyId = 'admin'
 ORDER BY