db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/xdocs changes.xml
Date Tue, 27 May 2003 16:28:23 GMT
mpoeschl    2003/05/27 09:28:22

  Modified:    src/test/org/apache/torque/util Tag: TORQUE_3_0_BRANCH
                        CriteriaTest.java
               src/java/org/apache/torque/util Tag: TORQUE_3_0_BRANCH
                        Criteria.java
               xdocs    Tag: TORQUE_3_0_BRANCH changes.xml
  Log:
  TRQ18: Criteria.addDate is broken
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.1  +22 -2     db-torque/src/test/org/apache/torque/util/CriteriaTest.java
  
  Index: CriteriaTest.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/test/org/apache/torque/util/CriteriaTest.java,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- CriteriaTest.java	28 Nov 2002 16:32:36 -0000	1.15
  +++ CriteriaTest.java	27 May 2003 16:28:12 -0000	1.15.2.1
  @@ -312,6 +312,27 @@
           assertEquals("TABLE.COLUMN=1", cc.toString());
       }
   
  +    public void testAddDate()
  +    {
  +        Criteria c = new Criteria();
  +        c.addDate("TABLE.DATE_COLUMN", 2003, 0, 22);
  +
  +        String expect = "SELECT  FROM TABLE WHERE TABLE.DATE_COLUMN='20030122000000'";
  +
  +        String result = null;
  +        try
  +        {
  +            result = BasePeer.createQueryString(c);
  +        }
  +        catch (TorqueException e)
  +        {
  +            e.printStackTrace();
  +            fail("TorqueException thrown in BasePeer.createQueryString()");
  +        }
  +        System.out.println(result);
  +        assertEquals(expect, result);
  +    }
  +
       public void testCurrentDate()
       {
           Criteria c = new Criteria()
  @@ -332,7 +353,6 @@
           }
   
           assertEquals(expect,result);
  -
       }
   
       public void testCountAster()
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.35.2.1  +78 -115   db-torque/src/java/org/apache/torque/util/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/java/org/apache/torque/util/Criteria.java,v
  retrieving revision 1.35
  retrieving revision 1.35.2.1
  diff -u -r1.35 -r1.35.2.1
  --- Criteria.java	28 Nov 2002 16:32:36 -0000	1.35
  +++ Criteria.java	27 May 2003 16:28:12 -0000	1.35.2.1
  @@ -900,7 +900,7 @@
        */
       public ObjectKey getObjectKey(String name)
       {
  -        return (ObjectKey)getCriterion(name).getValue();
  +        return (ObjectKey) getCriterion(name).getValue();
       }
   
       /**
  @@ -1108,8 +1108,8 @@
        * @param table Name of table which contains the column
        * @param column The column to run the comparison on
        * @param value An Object.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria add(String table,
  @@ -1117,11 +1117,13 @@
                           Object value,
                           SqlEnum comparison)
       {
  -        StringBuffer sb = new StringBuffer(table.length() + column.length() + 1);
  +        StringBuffer sb = new StringBuffer(table.length()
  +                + column.length() + 1);
           sb.append(table);
           sb.append('.');
           sb.append(column);
  -        super.put(sb.toString(),new Criterion(table, column, value, comparison));
  +        super.put(sb.toString(),
  +                  new Criterion(table, column, value, comparison));
           return this;
       }
   
  @@ -1156,8 +1158,8 @@
        *
        * @param column The column to run the comparison on
        * @param value A Boolean.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria add(String column, boolean value, SqlEnum comparison)
  @@ -1175,10 +1177,8 @@
        * add(column, new Integer(value), EQUAL);
        * </code>
        *
  -     *
        * @param column The column to run the comparison on
        * @param value An int.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria add(String column, int value)
  @@ -1198,8 +1198,8 @@
        *
        * @param column The column to run the comparison on
        * @param value An int.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria add(String column, int value, SqlEnum comparison)
  @@ -1219,7 +1219,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A long.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria add(String column, long value)
  @@ -1237,11 +1236,10 @@
        * add(column, new Long(value), comparison);
        * </code>
        *
  -     *
        * @param column The column to run the comparison on
        * @param value A long.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria add(String column, long value, SqlEnum comparison)
  @@ -1280,8 +1278,8 @@
        *
        * @param column The column to run the comparison on
        * @param value A float.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria add(String column, float value, SqlEnum comparison)
  @@ -1301,7 +1299,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A double.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria add(String column, double value)
  @@ -1321,8 +1318,8 @@
        *
        * @param column The column to run the comparison on
        * @param value A double.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria add(String column, double value, SqlEnum comparison)
  @@ -1362,13 +1359,14 @@
        *
        * @param column A String value to use as column.
        * @param year An int with the year.
  -     * @param month An int with the month.
  +     * @param month An int with the month. Month value is 0-based.
  +     *        e.g., 0 for January
        * @param date An int with the date.
        * @return A modified Criteria object.
        */
       public Criteria addDate(String column, int year, int month, int date)
       {
  -        add(column, new GregorianCalendar(year, month, date));
  +        add(column, new GregorianCalendar(year, month, date).getTime());
           return this;
       }
   
  @@ -1384,32 +1382,20 @@
        *
        * @param column The column to run the comparison on
        * @param year An int with the year.
  -     * @param month An int with the month.
  +     * @param month An int with the month. Month value is 0-based.
  +     *        e.g., 0 for January
        * @param date An int with the date.
  -     * @param comparison String describing how to compare the column with the value
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria addDate(String column, int year, int month, int date,
                               SqlEnum comparison)
       {
  -        add(column, new GregorianCalendar(year, month, date), comparison);
  -        return this;
  -    }
  -
  -    /* *
  -     * Convenience method to add a Key to Criteria.
  -     *
  -     * @param key A String value to use as key.
  -     * @param value A Key.
  -     * @return A modified Criteria object.
  -     * /
  -    public Criteria add (String key,
  -                         Key value)
  -    {
  -        add(key, value.getInternalObject());
  +        add(column, new GregorianCalendar(year, month, date).getTime(),
  +            comparison);
           return this;
       }
  -    */
   
       /**
        * This is the way that you should add a join of two tables.  For
  @@ -1877,7 +1863,9 @@
               sb.append("\nCurrent Query SQL (may not be complete or applicable): ")
                 .append(BasePeer.createQueryDisplayString(this));
           }
  -        catch (Exception exc) {}
  +        catch (Exception exc)
  +        {
  +        }
   
           return sb.toString();
       }
  @@ -1899,7 +1887,7 @@
           }
           else if (this.size() == ((Criteria) crit).size())
           {
  -            Criteria criteria = (Criteria)crit;
  +            Criteria criteria = (Criteria) crit;
               if (this.offset == criteria.getOffset()
                   && this.limit == criteria.getLimit()
                   && ignoreCase == criteria.isIgnoreCase()
  @@ -1912,7 +1900,7 @@
                  )
               {
                   isEquiv = true;
  -                for (Iterator it = criteria.keySet().iterator(); it.hasNext(); )
  +                for (Iterator it = criteria.keySet().iterator(); it.hasNext();)
                   {
                       String key = (String) it.next();
                       if (this.containsKey(key))
  @@ -1945,19 +1933,19 @@
        */
   
       /**
  -     * This method adds a prepared Criterion object to the Criteria as a having clause.
  -     * You can get a new, empty Criterion object with the
  +     * This method adds a prepared Criterion object to the Criteria as a having
  +     * clause. You can get a new, empty Criterion object with the
        * getNewCriterion() method.
        *
        * <p>
        * <code>
        * Criteria crit = new Criteria();
  -     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5), Criteria.LESS_THAN);
  +     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5),
  +     *         Criteria.LESS_THAN);
        * crit.addHaving(c);
        * </code>
        *
        * @param having A Criterion object
  -     *
        * @return A modified Criteria object.
        */
       public Criteria addHaving(Criterion having)
  @@ -1976,17 +1964,17 @@
        * <p>
        * <code>
        * Criteria crit = new Criteria();
  -     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5), Criteria.LESS_THAN);
  +     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5),
  +     *         Criteria.LESS_THAN);
        * crit.and(c);
        * </code>
        *
        * @param c A Criterion object
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(Criterion c)
       {
  -        Criterion oc = getCriterion(c.getTable()+'.'+c.getColumn());
  +        Criterion oc = getCriterion(c.getTable() + '.' + c.getColumn());
   
           if (oc == null)
           {
  @@ -2084,7 +2072,6 @@
        * @param table Name of the table which contains the column
        * @param column The column to run the comparison on
        * @param value An Object.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String table, String column, Object value)
  @@ -2111,14 +2098,15 @@
        * @param table Name of table which contains the column
        * @param column The column to run the comparison on
        * @param value An Object.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria and(String table, String column, Object value,
                           SqlEnum comparison)
       {
  -        StringBuffer sb = new StringBuffer(table.length() + column.length() + 1);
  +        StringBuffer sb = new StringBuffer(table.length()
  +                + column.length() + 1);
           sb.append(table);
           sb.append('.');
           sb.append(column);
  @@ -2128,7 +2116,7 @@
   
           if (oc == null)
           {
  -            super.put(sb.toString(),nc);
  +            super.put(sb.toString(), nc);
           }
           else
           {
  @@ -2148,7 +2136,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A Boolean.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, boolean value)
  @@ -2170,7 +2157,6 @@
        * @param value A Boolean.
        * @param comparison String describing how to compare the column
        * with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, boolean value, SqlEnum comparison)
  @@ -2188,10 +2174,8 @@
        * and(column, new Integer(value), EQUAL);
        * </code>
        *
  -     *
        * @param column The column to run the comparison on
        * @param value An int.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, int value)
  @@ -2209,11 +2193,9 @@
        * and(column, new Integer(value), comparison);
        * </code>
        *
  -     *
        * @param column The column to run the comparison on
        * @param value An int.
        * @param comparison String describing how to compare the column with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, int value, SqlEnum comparison)
  @@ -2231,10 +2213,8 @@
        * and(column, new Long(value), EQUAL);
        * </code>
        *
  -     *
        * @param column The column to run the comparison on
        * @param value A long.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, long value)
  @@ -2254,8 +2234,8 @@
        *
        * @param column The column to run the comparison on
        * @param value A long.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria and(String column, long value, SqlEnum comparison)
  @@ -2275,7 +2255,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A float.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, float value)
  @@ -2295,8 +2274,8 @@
        *
        * @param column The column to run the comparison on
        * @param value A float.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria and(String column, float value, SqlEnum comparison)
  @@ -2316,7 +2295,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A double.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria and(String column, double value)
  @@ -2336,8 +2314,8 @@
        *
        * @param column The column to run the comparison on
        * @param value A double.
  -     * @param comparison String describing how to compare the column with the value
  -     *
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria and(String column, double value, SqlEnum comparison)
  @@ -2382,7 +2360,8 @@
        * @param year An int with the year.
        * @param month An int with the month.
        * @param date An int with the date.
  -     * @param comparison String describing how to compare the column with the value
  +     * @param comparison String describing how to compare the column with
  +     *        the value
        * @return A modified Criteria object.
        */
       public Criteria andDate(String column, int year, int month, int date,
  @@ -2557,7 +2536,6 @@
        * </code>
        *
        * @param c A Criterion object
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(Criterion c)
  @@ -2624,7 +2602,6 @@
        * @param column The column to run the comparison on
        * @param value An Object.
        * @param comparison A String.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, Object value, SqlEnum comparison)
  @@ -2660,7 +2637,6 @@
        * @param table Name of the table which contains the column
        * @param column The column to run the comparison on
        * @param value An Object.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String table, String column, Object value)
  @@ -2688,7 +2664,6 @@
        * @param column The column to run the comparison on
        * @param value An Object.
        * @param comparison String describing how to compare the column with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String table, String column, Object value,
  @@ -2723,7 +2698,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A Boolean.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, boolean value)
  @@ -2745,7 +2719,6 @@
        * @param value A Boolean.
        * @param comparison String describing how to compare the column
        * with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, boolean value, SqlEnum comparison)
  @@ -2766,7 +2739,6 @@
        *
        * @param column The column to run the comparison on
        * @param value An int.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, int value)
  @@ -2789,7 +2761,6 @@
        * @param value An int.
        * @param comparison String describing how to compare the column
        * with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, int value, SqlEnum comparison)
  @@ -2807,10 +2778,8 @@
        * or(column, new Long(value), EQUAL);
        * </code>
        *
  -     *
        * @param column The column to run the comparison on
        * @param value A long.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, long value)
  @@ -2832,7 +2801,6 @@
        * @param value A long.
        * @param comparison String describing how to compare the column
        * with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, long value, SqlEnum comparison)
  @@ -2852,7 +2820,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A float.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, float value)
  @@ -2874,7 +2841,6 @@
        * @param value A float.
        * @param comparison String describing how to compare the column
        * with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, float value, SqlEnum comparison)
  @@ -2894,7 +2860,6 @@
        *
        * @param column The column to run the comparison on
        * @param value A double.
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, double value)
  @@ -2916,7 +2881,6 @@
        * @param value A double.
        * @param comparison String describing how to compare the column
        * with the value
  -     *
        * @return A modified Criteria object.
        */
       public Criteria or(String column, double value, SqlEnum comparison)
  @@ -2992,7 +2956,7 @@
        */
       public Criteria orIn(String column, Object[] values)
       {
  -        or(column, (Object)values, Criteria.IN);
  +        or(column, (Object) values, Criteria.IN);
           return this;
       }
   
  @@ -3135,7 +3099,7 @@
        */
       public void setBlobFlag(boolean b)
       {
  -        blobFlag = (b ? Boolean.TRUE: Boolean.FALSE);
  +        blobFlag = (b ? Boolean.TRUE : Boolean.FALSE);
       }
   
       /**
  @@ -3339,7 +3303,7 @@
           {
               this.db = v;
   
  -            for(int i = 0; i < this.clauses.size(); i++)
  +            for (int i = 0; i < this.clauses.size(); i++)
               {
                   ((Criterion) (clauses.get(i))).setDB(v);
               }
  @@ -3418,15 +3382,15 @@
               }
   
               Criterion clause = null;
  -            for(int j = 0; j < this.clauses.size(); j++)
  +            for (int j = 0; j < this.clauses.size(); j++)
               {
                   sb.append('(');
               }
               if (CUSTOM == comparison)
               {
  -                if (value != null && ! "".equals(value))
  +                if (value != null && !"".equals(value))
                   {
  -                    sb.append((String)value);
  +                    sb.append((String) value);
                   }
               }
               else
  @@ -3447,7 +3411,7 @@
                                       ignoreStringCase, getDb(), sb);
               }
   
  -            for(int i = 0; i < this.clauses.size(); i++)
  +            for (int i = 0; i < this.clauses.size(); i++)
               {
                   sb.append(this.conjunctions.get(i));
                   clause = (Criterion) (this.clauses.get(i));
  @@ -3473,7 +3437,7 @@
   
               DB db = getDb();
   
  -            for(int j = 0; j < this.clauses.size(); j++)
  +            for (int j = 0; j < this.clauses.size(); j++)
               {
                   sb.append('(');
               }
  @@ -3481,13 +3445,13 @@
               {
                   if (!"".equals(value))
                   {
  -                    sb.append((String)value);
  +                    sb.append((String) value);
                   }
               }
               else
               {
                   String field = null;
  -                if  (table == null)
  +                if (table == null)
                   {
                       field = column;
                   }
  @@ -3509,7 +3473,7 @@
   
                       if (value instanceof List)
                       {
  -                        value = ((List)value).toArray (new Object[0]);
  +                        value = ((List) value).toArray (new Object[0]);
                       }
   
                       for (int i = 0; i < Array.getLength(value); i++)
  @@ -3524,46 +3488,45 @@
                       StringBuffer inString = new StringBuffer();
                       inString.append('(')
                           .append(inClause.toString(",")).append(')');
  -
  -                    sb.append (inString.toString());
  +                    sb.append(inString.toString());
                   }
                   else
                   {
                       if (ignoreCase)
                       {
  -                        sb.append (db.ignoreCase(field))
  -                          .append (comparison)
  -                          .append (db.ignoreCase("?"));
  +                        sb.append(db.ignoreCase(field))
  +                          .append(comparison)
  +                          .append(db.ignoreCase("?"));
                       }
                       else
                       {
  -                        sb.append (field)
  -                          .append (comparison)
  -                          .append (" ? ");
  +                        sb.append(field)
  +                          .append(comparison)
  +                          .append(" ? ");
                       }
   
                       if (value instanceof java.util.Date)
                       {
                           params.add(new java.sql.Date(
  -                            ((java.util.Date)value).getTime()));
  +                            ((java.util.Date) value).getTime()));
                       }
                       else if (value instanceof DateKey)
                       {
                           params.add(new java.sql.Date(
  -                            ((DateKey)value).getDate().getTime()));
  +                            ((DateKey) value).getDate().getTime()));
                       }
                       else
                       {
  -                        params.add (value.toString());
  +                        params.add(value.toString());
                       }
                   }
               }
   
  -            for(int i = 0; i < this.clauses.size(); i++)
  +            for (int i = 0; i < this.clauses.size(); i++)
               {
                   sb.append(this.conjunctions.get(i));
                   Criterion clause = (Criterion) (this.clauses.get(i));
  -                clause.appendPsTo(sb,params);
  +                clause.appendPsTo(sb, params);
                   sb.append(')');
               }
           }
  @@ -3661,7 +3624,7 @@
                   h ^= column.hashCode();
               }
   
  -            for(int i = 0; i < this.clauses.size(); i++)
  +            for (int i = 0; i < this.clauses.size(); i++)
               {
                   h ^= ((Criterion) (clauses.get(i))).hashCode();
               }
  @@ -3688,7 +3651,7 @@
               if (c != null)
               {
                   s.add(c.getTable());
  -                for(int i = 0; i < c.getClauses().size(); i++)
  +                for (int i = 0; i < c.getClauses().size(); i++)
                   {
                       addCriterionTable((Criterion) (c.getClauses().get(i)), s);
                   }
  @@ -3721,7 +3684,7 @@
               if (c != null)
               {
                   a.add(c);
  -                for(int i = 0; i < c.getClauses().size(); i++)
  +                for (int i = 0; i < c.getClauses().size(); i++)
                   {
                       traverseCriterion((Criterion) (c.getClauses().get(i)), a);
                   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.54.2.7  +3 -0      db-torque/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/db-torque/xdocs/changes.xml,v
  retrieving revision 1.54.2.6
  retrieving revision 1.54.2.7
  diff -u -r1.54.2.6 -r1.54.2.7
  --- changes.xml	22 May 2003 21:58:05 -0000	1.54.2.6
  +++ changes.xml	27 May 2003 16:28:21 -0000	1.54.2.7
  @@ -43,6 +43,9 @@
   <p>
     <ul>
       <li>
  +      TRQ18: Criteria.addDate is broken
  +    </li>
  +    <li>
         TRQS90: SQLScanner reports wrong line numbers in Window platforms and
         behaves incorrectly when finding the minus sign
       </li>
  
  
  

Mime
View raw message