378 tst_Databases::safeDropTables(db, tableNames); |
380 tst_Databases::safeDropTables(db, tableNames); |
379 |
381 |
380 if (db.driverName().startsWith("QOCI")) { |
382 if (db.driverName().startsWith("QOCI")) { |
381 q.exec("drop user "+qTableName("CREATOR")+" cascade"); |
383 q.exec("drop user "+qTableName("CREATOR")+" cascade"); |
382 q.exec("drop user "+qTableName("APPUSER")+" cascade"); |
384 q.exec("drop user "+qTableName("APPUSER")+" cascade"); |
|
385 q.exec("DROP TABLE system."+qTableName("mypassword")); |
383 |
386 |
384 } |
387 } |
385 } |
388 } |
386 |
389 |
387 void tst_QSqlDatabase::populateTestTables(QSqlDatabase db) |
390 void tst_QSqlDatabase::populateTestTables(QSqlDatabase db) |
763 int i = 0; |
766 int i = 0; |
764 for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { |
767 for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { |
765 rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val); |
768 rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val); |
766 // qDebug(QString("inserting %1 into %2").arg(fieldDefs[ i ].val.toString()).arg(fieldDefs[ i ].fieldName())); |
769 // qDebug(QString("inserting %1 into %2").arg(fieldDefs[ i ].val.toString()).arg(fieldDefs[ i ].fieldName())); |
767 } |
770 } |
768 if (!cur.insert()) { |
771 QVERIFY_SQL(cur, insert()); |
769 QFAIL(QString("Couldn't insert record: %1 %2").arg(cur.lastError().databaseText()).arg(cur.lastError().driverText())); |
|
770 } |
|
771 cur.setForwardOnly(true); |
772 cur.setForwardOnly(true); |
772 QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1))); |
773 QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1))); |
773 QVERIFY_SQL(cur, next()); |
774 QVERIFY_SQL(cur, next()); |
774 |
775 |
775 for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { |
776 for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { |
828 if (fieldDefs[ i ].fieldName(), fieldDefs[ i ].nullable) |
829 if (fieldDefs[ i ].fieldName(), fieldDefs[ i ].nullable) |
829 rec->setNull(fieldDefs[ i ].fieldName()); |
830 rec->setNull(fieldDefs[ i ].fieldName()); |
830 else |
831 else |
831 rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val); |
832 rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val); |
832 } |
833 } |
833 if (!cur.insert()) { |
834 QVERIFY_SQL(cur, insert()); |
834 QFAIL(QString("Couldn't insert record: %1 %2").arg(cur.lastError().databaseText()).arg(cur.lastError().driverText())); |
|
835 } |
|
836 cur.setForwardOnly(true); |
835 cur.setForwardOnly(true); |
837 QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1))); |
836 QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1))); |
838 QVERIFY_SQL(cur, next()); |
837 QVERIFY_SQL(cur, next()); |
839 |
838 |
840 for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { |
839 for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { |
932 FieldDef("varchar(20)", QVariant::String, QString("blah2")), |
931 FieldDef("varchar(20)", QVariant::String, QString("blah2")), |
933 FieldDef("nchar(20)", QVariant::String, QString("blah3")), |
932 FieldDef("nchar(20)", QVariant::String, QString("blah3")), |
934 FieldDef("nvarchar2(20)", QVariant::String, QString("blah4")), |
933 FieldDef("nvarchar2(20)", QVariant::String, QString("blah4")), |
935 FieldDef("number(10,5)", QVariant::Double, 1.1234567), |
934 FieldDef("number(10,5)", QVariant::Double, 1.1234567), |
936 FieldDef("date", QVariant::DateTime, dt), |
935 FieldDef("date", QVariant::DateTime, dt), |
937 #ifdef QT3_SUPPORT |
936 FieldDef("long raw", QVariant::ByteArray, QByteArray("blah5")), |
938 //X? FieldDef("long raw", QVariant::ByteArray, QByteArray(Q3CString("blah5"))), |
937 FieldDef("raw(2000)", QVariant::ByteArray, QByteArray("blah6"), false), |
939 FieldDef("raw(2000)", QVariant::ByteArray, QByteArray(Q3CString("blah6")), false), |
938 FieldDef("blob", QVariant::ByteArray, QByteArray("blah7")), |
940 FieldDef("blob", QVariant::ByteArray, QByteArray(Q3CString("blah7"))), |
939 FieldDef("clob", QVariant::String, QString("blah8")), |
941 #endif |
940 FieldDef("nclob", QVariant::String, QString("blah9")), |
942 //FIXME FieldDef("clob", QVariant::CString, Q3CString("blah8")), |
941 FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")), |
943 //FIXME FieldDef("nclob", QVariant::CString, Q3CString("blah9")), |
|
944 //X FieldDef("bfile", QVariant::ByteArray, QByteArray(Q3CString("blah10"))), |
|
945 |
942 |
946 intytm, |
943 intytm, |
947 intdts, |
944 // intdts, |
948 tsdef, |
945 // tsdef, |
949 tstzdef, |
946 // tstzdef, |
950 tsltzdef, |
947 // tsltzdef, |
951 FieldDef() |
948 FieldDef() |
952 }; |
949 }; |
953 |
950 |
954 const int fieldCount = createFieldTable(fieldDefs, db); |
951 const int fieldCount = createFieldTable(fieldDefs, db); |
955 QVERIFY(fieldCount > 0); |
952 QVERIFY(fieldCount > 0); |
1232 FieldDef("clob", QVariant::String, QString("123.45")), |
1229 FieldDef("clob", QVariant::String, QString("123.45")), |
1233 FieldDef("text", QVariant::String, QString("123.456")), |
1230 FieldDef("text", QVariant::String, QString("123.456")), |
1234 |
1231 |
1235 FieldDef("integer", QVariant::Int, QVariant(13)), |
1232 FieldDef("integer", QVariant::Int, QVariant(13)), |
1236 FieldDef("int", QVariant::Int, QVariant(12)), |
1233 FieldDef("int", QVariant::Int, QVariant(12)), |
|
1234 FieldDef("real", QVariant::String, QVariant(1.234567890123456)), |
1237 |
1235 |
1238 FieldDef() |
1236 FieldDef() |
1239 }; |
1237 }; |
1240 |
1238 |
1241 const int fieldCount = createFieldTable(fieldDefs, db); |
1239 const int fieldCount = createFieldTable(fieldDefs, db); |
2478 QVERIFY_SQL(q, exec("begin")); |
2476 QVERIFY_SQL(q, exec("begin")); |
2479 QVERIFY_SQL(q, exec("insert into "+qTableName("qtest")+" VALUES (54, 'foo', 'foo', 54.54)")); |
2477 QVERIFY_SQL(q, exec("insert into "+qTableName("qtest")+" VALUES (54, 'foo', 'foo', 54.54)")); |
2480 QVERIFY_SQL(q, exec("savepoint foo")); |
2478 QVERIFY_SQL(q, exec("savepoint foo")); |
2481 } |
2479 } |
2482 |
2480 |
|
2481 void tst_QSqlDatabase::oci_tables() |
|
2482 { |
|
2483 QFETCH(QString, dbName); |
|
2484 QSqlDatabase db = QSqlDatabase::database(dbName); |
|
2485 CHECK_DATABASE(db); |
|
2486 QSqlQuery q(db); |
|
2487 QString systemTableName("system."+qTableName("mypassword")); |
|
2488 QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))")); |
|
2489 QVERIFY(!db.tables().contains(systemTableName.toUpper())); |
|
2490 QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper())); |
|
2491 } |
|
2492 |
2483 QTEST_MAIN(tst_QSqlDatabase) |
2493 QTEST_MAIN(tst_QSqlDatabase) |
2484 #include "tst_qsqldatabase.moc" |
2494 #include "tst_qsqldatabase.moc" |