db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/util SqlHelper.java
Date Wed, 03 Dec 2003 19:12:32 GMT
brj         2003/12/03 11:12:32

  Modified:    src/java/org/apache/ojb/broker/util SqlHelper.java
  Log:
  fixed problem with multi arg functions
  
  Revision  Changes    Path
  1.18      +21 -26    db-ojb/src/java/org/apache/ojb/broker/util/SqlHelper.java
  
  Index: SqlHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/SqlHelper.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SqlHelper.java	28 Nov 2003 14:39:59 -0000	1.17
  +++ SqlHelper.java	3 Dec 2003 19:12:32 -0000	1.18
  @@ -114,10 +114,6 @@
        */
       public static PathInfo splitPath(String aPath)
       {
  -        int braceBegin;
  -        int braceEnd;
  -        int colBegin;
  -        String betweenBraces;
           String prefix = null;
           String suffix = null;
           String colName = aPath;
  @@ -127,32 +123,31 @@
               return new PathInfo(null, null, null);
           }
   
  -        braceBegin = aPath.indexOf("(");
  -        if (braceBegin >= 0)
  +        int braceBegin = aPath.indexOf("(");
  +        int braceEnd = aPath.lastIndexOf(")");
  +
  +        if (braceBegin >= 0 && braceEnd >= 0)
           {
  -            braceEnd = aPath.lastIndexOf(")");
  -            if (braceEnd >= 0)
  -            {
  +                int colBegin;
  +                int colEnd;
  +                String betweenBraces;
  +
                   betweenBraces = aPath.substring(braceBegin + 1, braceEnd).trim();
  +
                   // look for ie 'distinct name'
  -                colBegin = betweenBraces.lastIndexOf(" ");
  -                if (colBegin >= 0)
  -                {
  -                    prefix =
  -                        aPath.substring(0, braceBegin + 1)
  -                            + betweenBraces.substring(0, colBegin + 1);
  -                    colName = betweenBraces.substring(colBegin + 1).trim();
  -                }
  -                else
  -                {
  -                    prefix = aPath.substring(0, braceBegin + 1);
  -                    colName = betweenBraces;
  -                }
  -                suffix = aPath.substring(braceEnd);
  -            }
  +                colBegin = betweenBraces.indexOf(" ");
  +                // look for multiarg fuction like to_char(col,'format_mask')
  +                colEnd = betweenBraces.indexOf(",");               
  +                colEnd = colEnd > 0 ? colEnd : betweenBraces.length();
  +
  +                prefix = aPath.substring(0, braceBegin + 1) +
  +                            betweenBraces.substring(0, colBegin + 1);
  +                colName = betweenBraces.substring(colBegin + 1, colEnd);
  +                suffix = betweenBraces.substring(colEnd) + 
  +                            aPath.substring(braceEnd);
           }
   
  -        return new PathInfo(prefix, colName, suffix);
  +        return new PathInfo(prefix, colName.trim(), suffix);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message