1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the test suite of the Qt Toolkit. |
7 ** This file is part of the test suite of the Qt Toolkit. |
8 ** |
8 ** |
901 QFETCH(QString, dbName); |
901 QFETCH(QString, dbName); |
902 QSqlDatabase db = QSqlDatabase::database(dbName); |
902 QSqlDatabase db = QSqlDatabase::database(dbName); |
903 CHECK_DATABASE(db); |
903 CHECK_DATABASE(db); |
904 |
904 |
905 // runtime check for Oracle version since V8 doesn't support TIMESTAMPs |
905 // runtime check for Oracle version since V8 doesn't support TIMESTAMPs |
906 if (tst_Databases::getOraVersion(db) >= 9) { |
906 if (tst_Databases::getOraVersion(db) >= 9) |
907 qDebug("Detected Oracle >= 9, TIMESTAMP test enabled"); |
907 hasTimeStamp = true; |
908 hasTimeStamp = true; |
|
909 } else { |
|
910 qDebug("Detected Oracle < 9, TIMESTAMP test disabled"); |
|
911 } |
|
912 |
908 |
913 FieldDef tsdef; |
909 FieldDef tsdef; |
914 FieldDef tstzdef; |
910 FieldDef tstzdef; |
915 FieldDef tsltzdef; |
911 FieldDef tsltzdef; |
916 FieldDef intytm; |
912 FieldDef intytm; |
917 FieldDef intdts; |
913 FieldDef intdts; |
918 |
914 |
919 static const QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0)); |
915 static const QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0)); |
920 |
916 |
921 if (hasTimeStamp) { |
917 if (hasTimeStamp) { |
922 tsdef = FieldDef("timestamp", QVariant::DateTime, dt); |
918 tsdef = FieldDef("timestamp", QVariant::DateTime, dt); |
923 tstzdef = FieldDef("timestamp with time zone", QVariant::DateTime, dt); |
919 tstzdef = FieldDef("timestamp with time zone", QVariant::DateTime, dt); |
924 tsltzdef = FieldDef("timestamp with local time zone", QVariant::DateTime, dt); |
920 tsltzdef = FieldDef("timestamp with local time zone", QVariant::DateTime, dt); |
925 intytm = FieldDef("interval year to month", QVariant::String, QString("+01-01")); |
921 intytm = FieldDef("interval year to month", QVariant::String, QString("+01-01")); |
926 intdts = FieldDef("interval day to second", QVariant::String, QString("+01 00:00:01.000000")); |
922 intdts = FieldDef("interval day to second", QVariant::String, QString("+01 00:00:01.000000")); |
927 } |
923 } |
928 |
924 |
929 const FieldDef fieldDefs[] = { |
925 const FieldDef fieldDefs[] = { |
930 FieldDef("char(20)", QVariant::String, QString("blah1")), |
926 FieldDef("char(20)", QVariant::String, QString("blah1")), |
931 FieldDef("varchar(20)", QVariant::String, QString("blah2")), |
927 FieldDef("varchar(20)", QVariant::String, QString("blah2")), |
936 FieldDef("long raw", QVariant::ByteArray, QByteArray("blah5")), |
932 FieldDef("long raw", QVariant::ByteArray, QByteArray("blah5")), |
937 FieldDef("raw(2000)", QVariant::ByteArray, QByteArray("blah6"), false), |
933 FieldDef("raw(2000)", QVariant::ByteArray, QByteArray("blah6"), false), |
938 FieldDef("blob", QVariant::ByteArray, QByteArray("blah7")), |
934 FieldDef("blob", QVariant::ByteArray, QByteArray("blah7")), |
939 FieldDef("clob", QVariant::String, QString("blah8")), |
935 FieldDef("clob", QVariant::String, QString("blah8")), |
940 FieldDef("nclob", QVariant::String, QString("blah9")), |
936 FieldDef("nclob", QVariant::String, QString("blah9")), |
941 FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")), |
937 // FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")), |
942 |
938 |
943 intytm, |
939 intytm, |
944 // intdts, |
940 intdts, |
945 // tsdef, |
941 tsdef, |
946 // tstzdef, |
942 tstzdef, |
947 // tsltzdef, |
943 tsltzdef, |
948 FieldDef() |
944 FieldDef() |
949 }; |
945 }; |
950 |
946 |
951 const int fieldCount = createFieldTable(fieldDefs, db); |
947 const int fieldCount = createFieldTable(fieldDefs, db); |
952 QVERIFY(fieldCount > 0); |
948 QVERIFY(fieldCount > 0); |
953 |
949 |
954 commonFieldTest(fieldDefs, db, fieldCount); |
950 commonFieldTest(fieldDefs, db, fieldCount); |
955 checkNullValues(fieldDefs, db); |
951 checkNullValues(fieldDefs, db); |
956 for (int i = 0; i < ITERATION_COUNT; ++i) { |
952 for (int i = 0; i < ITERATION_COUNT; ++i) |
957 checkValues(fieldDefs, db); |
953 checkValues(fieldDefs, db); |
958 } |
|
959 |
954 |
960 // some additional tests |
955 // some additional tests |
961 QSqlRecord rec = db.record(qTableName("qtestfields")); |
956 QSqlRecord rec = db.record(qTableName("qtestfields")); |
962 QCOMPARE(rec.field("T_NUMBER").length(), 10); |
957 QCOMPARE(rec.field("T_NUMBER").length(), 10); |
963 QCOMPARE(rec.field("T_NUMBER").precision(), 5); |
958 QCOMPARE(rec.field("T_NUMBER").precision(), 5); |