You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2009/11/13 08:24:42 UTC

svn commit: r835765 - /ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy

Author: doogie
Date: Fri Nov 13 07:24:41 2009
New Revision: 835765

URL: http://svn.apache.org/viewvc?rev=835765&view=rev
Log:
More example usage, shows condition parsing, and makes use of more
sql syntax.

Modified:
    ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy

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=835765&r1=835764&r2=835765&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy (original)
+++ ofbiz/trunk/framework/webslinger/websites/webslinger/www/TestSQL.groovy Fri Nov 13 07:24:41 2009
@@ -1,23 +1,31 @@
 import java.util.concurrent.Callable
-import org.ofbiz.entity.sql.Parser
+import org.ofbiz.entity.sql.SQLUtil
 import org.ofbiz.entity.transaction.TransactionUtil
 response.contentType = 'text/html'
 def delegator = request.delegator
+
+def ec1 = SQLUtil.parseCondition("partyId = 'foo' AND partyTypeId = 'PARTY_GROUP'")
+println("ec1=$ec1")
+def ec2 = SQLUtil.parseCondition(ec1.toString())
+println("ec2=$ec2")
+//return
+
 def sql = """
 select
-	a.*,
+    a.partyId,
+    a.partyTypeId as type,
 	b.firstName,
-	b.lastName
+	b.lastName,
+    c.groupName
 FROM
-	Party a JOIN Person b ON a.partyId = b.partyId
+	Party a LEFT JOIN Person b ON a.partyId = b.partyId LEFT JOIN PartyGroup c on a.partyId = c.partyId
 WHERE
-	a.partyId='admin'
-OFFSET 5
-LIMIT 10
+    partyId = 'admin'
+ORDER BY
+    lastName
 ;
 """
-def parser = new Parser(new ByteArrayInputStream(sql.bytes))
-def sqlSelect = parser.Select()
+def sqlSelect = SQLUtil.parseSelect(sql)
 
 TransactionUtil.doNewTransaction("Test", [call: {
     def eli