@@ -194,6 +194,8 @@ private slots:
194
194
void sqlServerReturn0_data () { generic_data (); }
195
195
void sqlServerReturn0 ();
196
196
197
+ void QTBUG_5251_data () { generic_data (" QPSQL" ); }
198
+ void QTBUG_5251 ();
197
199
198
200
private:
199
201
// returns all database connections
@@ -2880,5 +2882,35 @@ void tst_QSqlQuery::sqlServerReturn0()
2880
2882
QVERIFY_SQL (q, next ());
2881
2883
}
2882
2884
2885
+ void tst_QSqlQuery::QTBUG_5251 ()
2886
+ {
2887
+ QFETCH ( QString, dbName );
2888
+ QSqlDatabase db = QSqlDatabase::database ( dbName );
2889
+ CHECK_DATABASE ( db );
2890
+
2891
+ if (!db.driverName ().startsWith ( " QPSQL" )) return ;
2892
+
2893
+ QSqlQuery q (db);
2894
+ q.exec (" DROP TABLE " + qTableName (" timetest" ));
2895
+ QVERIFY_SQL (q, exec (" CREATE TABLE " + qTableName (" timetest" ) + " (t TIME)" ));
2896
+ QVERIFY_SQL (q, exec (" INSERT INTO " + qTableName (" timetest" ) + " VALUES ('1:2:3.666')" ));
2897
+
2898
+ QSqlTableModel timetestModel (0 ,db);
2899
+ timetestModel.setEditStrategy (QSqlTableModel::OnManualSubmit);
2900
+ timetestModel.setTable (qTableName (" timetest" ));
2901
+ QVERIFY_SQL (timetestModel, select ());
2902
+
2903
+ QCOMPARE (timetestModel.record (0 ).field (0 ).value ().toTime ().toString (" HH:mm:ss.zzz" ), QString (" 01:02:03.666" ));
2904
+ QVERIFY_SQL (timetestModel,setData (timetestModel.index (0 , 0 ), QTime (0 ,12 ,34 ,500 )));
2905
+ QCOMPARE (timetestModel.record (0 ).field (0 ).value ().toTime ().toString (" HH:mm:ss.zzz" ), QString (" 00:12:34.500" ));
2906
+ QVERIFY_SQL (timetestModel, submitAll ());
2907
+ QCOMPARE (timetestModel.record (0 ).field (0 ).value ().toTime ().toString (" HH:mm:ss.zzz" ), QString (" 00:12:34.500" ));
2908
+
2909
+ QVERIFY_SQL (q, exec (" UPDATE " + qTableName (" timetest" ) + " SET t = '0:11:22.33'" ));
2910
+ QVERIFY_SQL (timetestModel, select ());
2911
+ QCOMPARE (timetestModel.record (0 ).field (0 ).value ().toTime ().toString (" HH:mm:ss.zzz" ), QString (" 00:11:22.330" ));
2912
+
2913
+ }
2914
+
2883
2915
QTEST_MAIN ( tst_QSqlQuery )
2884
2916
#include " tst_qsqlquery.moc"
0 commit comments