File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -301,8 +301,25 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature& feature )
301
301
{
302
302
QVariant v = mQuery ->value ( i );
303
303
const QgsField &fld = mSource ->mFields .at ( mAttributesToFetch .at ( i ) );
304
- if ( v.type () != fld.type () )
304
+
305
+ // special handling for time fields
306
+ if ( fld.type () == QVariant::Time && v.type () == QVariant::ByteArray )
307
+ {
308
+ QList<QByteArray> parts = v.toByteArray ().split ( ' \0 ' );
309
+ if ( parts.count () >= 3 )
310
+ {
311
+ int hours = QString ( parts.at ( 0 ) ).at ( 0 ).toAscii ();
312
+ int minutes = QString ( parts.at ( 1 ) ).at ( 0 ).toAscii ();
313
+ int seconds = QString ( parts.at ( 2 ) ).at ( 0 ).toAscii ();
314
+ v = QTime ( hours, minutes, seconds );
315
+ }
316
+ else
317
+ v = QgsVectorDataProvider::convertValue ( fld.type (), v.toString () );
318
+ }
319
+ else if ( v.type () != fld.type () )
320
+ {
305
321
v = QgsVectorDataProvider::convertValue ( fld.type (), v.toString () );
322
+ }
306
323
feature.setAttribute ( mAttributesToFetch .at ( i ), v );
307
324
}
308
325
You can’t perform that action at this time.
0 commit comments