MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:jbalint Date:February 2 2007 10:58pm
Subject:Connector/ODBC 5 commit: r786 - trunk/SDK/MYSQLPlus/Library
View as plain text  
Modified:
   trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp
Log:
Fixed getting timestamp values from time result columns. (fix bug#25846)

Modified: trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp	2007-02-01 09:22:19 UTC (rev 785)
+++ trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp	2007-02-02 22:58:01 UTC (rev 786)
@@ -1768,6 +1768,8 @@
     pResultGetData->nBytesTotal     = sizeof(SQL_TIMESTAMP_STRUCT);
     pResultGetData->nBytesRemaining = 0;
 
+    QVariant val = vectorRows[pResultGetData->nRow][pResultGetData->nColumn - 1];
+
     /*!
         \internal ODBC RULE
 
@@ -1778,11 +1780,27 @@
 
     SQL_TIMESTAMP_STRUCT *pTimeStampTarget = (SQL_TIMESTAMP_STRUCT
*)pResultGetData->pTarget;
 
-    if ( !vectorRows[pResultGetData->nRow][pResultGetData->nColumn - 1].canConvert(
QVariant::DateTime ) ) 
+    if ( !val.canConvert( QVariant::DateTime ) ) 
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::STATE_07006 ) );
 
-    QDateTime t = vectorRows[pResultGetData->nRow][pResultGetData->nColumn -
1].toDateTime();
+    QDateTime t;
 
+    int len = val.toString().size();
+
+    /* if we only have the time, use today's date per spec */
+    if ( pResultGetData->pImpRowDescRec->getConciseType() == SQL_TYPE_TIME ||
+            /* strings that LOOK like time 12:30 or 12:30:00 */
+            len == 5 || len == 8)
+    {
+        t = QDateTime::currentDateTime();
+        t.setTime( val.toTime() );
+    }
+    else
+    {
+        t = val.toDateTime();
+    }
+
+    /* we can only return valid dates */
     if ( t.isNull() || !t.isValid() )
     {
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::STATE_22007 ) );

Thread
Connector/ODBC 5 commit: r786 - trunk/SDK/MYSQLPlus/Libraryjbalint2 Feb