db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/sql SqlQueryStatement.java
Date Thu, 02 Jan 2003 09:37:58 GMT
brj         2003/01/02 01:37:58

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  support columns like "count(distinct x)"
  
  Revision  Changes    Path
  1.16      +13 -4     jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SqlQueryStatement.java	24 Dec 2002 12:57:51 -0000	1.15
  +++ SqlQueryStatement.java	2 Jan 2003 09:37:58 -0000	1.16
  @@ -147,17 +147,27 @@
           FieldDescriptor fld = null;
           int braceBegin;
           int braceEnd;
  +        int colBegin;
           String functionName;
           String colName;
           int sp;
           TableAlias alias = null;
   
  +        // BRJ : look for functions ie: count(x) or count(distinct x)
           braceBegin = attr.indexOf("(");
           braceEnd = attr.indexOf(")");
           if (braceBegin >= 0 && braceEnd >= 0)
           {
  -            functionName = attr.substring(0, braceBegin);
  -            colName = attr.substring(braceBegin + 1, braceEnd).trim();
  +            // BRJ : look for count(distinct x)
  +            colBegin = attr.indexOf(" ", braceBegin); 
  +            if (colBegin < 0)
  +            {
  +                colBegin = braceBegin;
  +            }
  +
  +            // BRJ : functionName includes starting brace
  +            functionName = attr.substring(0, colBegin + 1);  
  +            colName = attr.substring(colBegin + 1, braceEnd).trim();
           }
           else
           {
  @@ -227,7 +237,6 @@
           if (functionName != null) // rebuild function
           {
               buf.append(functionName);
  -            buf.append("(");
           }
   
           if (fld != null)
  
  
  

Mime
View raw message