You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by John McNally <jm...@collab.net> on 2001/09/04 22:59:02 UTC

Re: cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/util/db SqlExpression.java

fedor@apache.org wrote:
> 
<snip>
> 
> 
>   1.2       +4 -2      jakarta-turbine-2/src/java/org/apache/turbine/util/db/SqlExpression.java
> 
>   Index: SqlExpression.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/db/SqlExpression.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- SqlExpression.java        2001/08/16 05:09:49     1.1
>   +++ SqlExpression.java        2001/09/01 08:37:14     1.2
>   @@ -59,6 +59,7 @@
>    import java.util.Date;
>    import java.util.Iterator;
>    import java.util.List;
>   +import java.sql.Timestamp;
> 
>    import org.apache.turbine.om.DateKey;
>    import org.apache.turbine.om.ObjectKey;
>   @@ -79,7 +80,7 @@
>     *
>     * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
>     * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
>   - * @version $Id: SqlExpression.java,v 1.1 2001/08/16 05:09:49 jvanzyl Exp $
>   + * @version $Id: SqlExpression.java,v 1.2 2001/09/01 08:37:14 fedor Exp $
>     */
>    public class SqlExpression
>    {
>   @@ -290,7 +291,8 @@
>               else if( criteria instanceof java.util.Date ||
>                        criteria instanceof DateKey)
>               {
>   -               criteria = db.getDateString(criteria.toString());
>   +               Date dt = criteria instanceof Date?(Date) criteria:((DateKey)criteria).getDate();
>   +               criteria = "{ts '" + new Timestamp(dt.getTime()).toString() + "'}";
>               }
>               else if( criteria instanceof Boolean )
>               {
> 
> 

This will cause a loss of precision, if criteria is a Timestamp the
getTime() method only returns integral seconds.  

I have a question/reservation about the jdbc escape.  If the column is a
date column of some type other than timestamp, is the driver expected to
parse the jdbc escape properly?  It seems conceivable that it may just
throw an exception.

john mcnally

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