db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r537252 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/DateTime.java testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
Date Fri, 11 May 2007 18:06:17 GMT
Author: kmarsden
Date: Fri May 11 11:06:16 2007
New Revision: 537252

URL: http://svn.apache.org/viewvc?view=rev&rev=537252
Log:
DERBY-889 with client getTimestamp on a TIME column will print the date 1900-01-01 instead
of the current date

Committed Bryan's fix unchanged and enabled test cases in TimeHandlingTest
Contributed by Bryan Pendleton


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java?view=diff&rev=537252&r1=537251&r2=537252
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java Fri May 11 11:06:16
2007
@@ -477,18 +477,21 @@
                 10 * (((int) time.charAt(6)) - zeroBase) +
                 (((int) time.charAt(7)) - zeroBase);
 
+        // The SQL standard specifies that the date portion of the returned
+        // timestamp should be set to the current date. See DERBY-889 for
+        // more details.
+        java.util.Date today = new java.util.Date();
         if (recyclableTimestamp == null) {
-            return new java.sql.Timestamp(0, 0, 1, hour, minute, second, 0);
-        } else {
-            recyclableTimestamp.setYear(0);
-            recyclableTimestamp.setMonth(0);
-            recyclableTimestamp.setDate(1);
-            recyclableTimestamp.setHours(hour);
-            recyclableTimestamp.setMinutes(minute);
-            recyclableTimestamp.setSeconds(second);
-            recyclableTimestamp.setNanos(0);
-            return recyclableTimestamp;
+            recyclableTimestamp = new java.sql.Timestamp(today.getTime());
         }
+        else {
+            recyclableTimestamp.setTime(today.getTime());
+        }
+        recyclableTimestamp.setHours(hour);
+        recyclableTimestamp.setMinutes(minute);
+        recyclableTimestamp.setSeconds(second);
+        recyclableTimestamp.setNanos(0);
+        return recyclableTimestamp;
     }
     
     

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java?view=diff&rev=537252&r1=537251&r2=537252
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TimeHandlingTest.java
Fri May 11 11:06:16 2007
@@ -75,11 +75,6 @@
     {
         TestSuite suite = new TestSuite(TimeHandlingTest.class);
         
-        // Once DERBY-889 is fixed the methods should be renamed
-        // and these lines removed so they are added under the default mechanism.
-        suite.addTest(new TimeHandlingTest("derby889testInertTime"));
-        suite.addTest(new TimeHandlingTest("derby889testCurrentTime"));
-        
         suite.addTest(TestConfiguration.clientServerSuite(TimeHandlingTest.class));
         
         return new CleanDatabaseTestSetup(suite) {
@@ -149,13 +144,11 @@
      * The returned values are fetched using checkTimeValue thus inheriting
      * all the checks within that method.
      * <BR>
-     * Once DERBY-889 is fixed this test should be renamed so that it
-     * loses the prefix derby889 (and the specific adding of this test
-     * in the suite() method removed.
+     * 
      * @throws SQLException
      * @throws UnsupportedEncodingException 
      */
-    public void derby889testInertTime() throws SQLException, UnsupportedEncodingException
+    public void testInertTime() throws SQLException, UnsupportedEncodingException
     {
         getConnection().setAutoCommit(false);
         // Insert a set of time values, 
@@ -252,13 +245,11 @@
      * is correctly between the start time of the statement
      * execution and the first fetch or completion.
      * <BR>
-     * Once DERBY-889 is fixed this test should be renamed so that it
-     * loses the prefix derby889 (and the specific adding of this test
-     * in the suite() method removed.
+     * 
      * @throws SQLException
      * @throws InterruptedException 
      */
-    public void derby889testCurrentTime() throws SQLException, InterruptedException
+    public void testCurrentTime() throws SQLException, InterruptedException
     {      
         currentFunctionTests(Types.TIME, CURRENT_TIME_FUNCTIONS);      
     }



Mime
View raw message