This content has been marked as final.
Show 4 replies
-
1. Re: org.jboss.seam.framework Query too case sensitive
gavin.king Jan 16, 2007 7:43 PM (in response to codelion)Please submit a patch (in diff format) to CVS.
-
2. Re: org.jboss.seam.framework Query too case sensitive
codelion Jan 18, 2007 8:00 AM (in response to codelion)Here is my code. I'll try again with CVS, I've figured out anonymous CVS for Seam, I've figured out you want JIRA to submit diff, but both with TortoiseCVS and with Eclipse (to a Windows machine) I'm getting double line breaks, so my diff is wrong. I try again in a couple of days.
Meanwhile so the suspense doesn't become unbearable...import java.util.regex.Matcher; import java.util.regex.Pattern; private static final Pattern FROM_PATTERN = Pattern.compile ("[^a-z0-9_](from)[^a-z0-9_]",Pattern.CASE_INSENSITIVE); private static final Pattern ORDER_PATTERN = Pattern.compile ("[^a-z0-9_](order)[^a-z0-9_]",Pattern.CASE_INSENSITIVE); protected String getCountEjbql() { String ejbql = getRenderedEjbql(); // Matcher fromMatcher = FROM_PATTERN.matcher(ejbql); boolean foundFrom = fromMatcher.find(); int fromLoc = fromMatcher.start(1); // Matcher orderMatcher = ORDER_PATTERN.matcher(ejbql); boolean foundOrder = orderMatcher.find(); int orderLoc = foundOrder ? orderMatcher.start(1) : ejbql.length(); // return "select count(*) " + ejbql.substring(fromLoc, orderLoc); }
These patterns could use some more research, but now they prevent mismatches for tokens named orderForm and fromAddress, and they're case-insensitive. -
3. Re: org.jboss.seam.framework Query too case sensitive
codelion Jan 23, 2007 4:43 AM (in response to codelion)Had no luck with diff against CVS with Eclipse on Windows, neither with TortoiseCVS. Probably a line-feed on platform problem. Then tried WinCVS. Is this a good format?
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/framework/Query.java,v retrieving revision 1.14 diff -u -w -b -r1.14 Query.java --- Query.java 16 Dec 2006 14:06:58 -0000 1.14 +++ Query.java 23 Jan 2007 09:22:35 -0000 @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.faces.model.DataModel; @@ -34,6 +36,11 @@ public abstract Object getSingleResult(); public abstract Long getResultCount(); + private static final Pattern FROM_PATTERN = + Pattern.compile("[^a-z0-9_](from)[^a-z0-9_]", Pattern.CASE_INSENSITIVE); + private static final Pattern ORDER_PATTERN = + Pattern.compile("[^a-z0-9_](order)[^a-z0-9_]", Pattern.CASE_INSENSITIVE); + @Create public void validate() { @@ -205,9 +212,15 @@ protected String getCountEjbql() { String ejbql = getRenderedEjbql(); - int fromLoc = ejbql.indexOf("from"); - int orderLoc = ejbql.indexOf("order"); - if (orderLoc<0) orderLoc = ejbql.length(); + + Matcher fromMatcher = FROM_PATTERN.matcher(ejbql); + boolean foundFrom = fromMatcher.find(); + int fromLoc = fromMatcher.start(1); + + Matcher orderMatcher = ORDER_PATTERN.matcher(ejbql); + boolean foundOrder = orderMatcher.find(); + int orderLoc = foundOrder ? orderMatcher.start(1) : ejbql.length(); + return "select count(*) " + ejbql.substring(fromLoc, orderLoc); }
I'll be happy to write it up in JIRA (first report problem then supply this solution) if this is an acceptable format. Let me know. -
4. Re: org.jboss.seam.framework Query too case sensitive
pmuir Jan 23, 2007 5:32 AM (in response to codelion)Yes, that's a patch :) You can just attach that as a file to a JIRA issue. Thanks.