Fix sql tests in respect to Oracle databases
Oracle has a limitation of 30 characters for a tablename so the main change is to account for this, which meant changing all the usages of qTableName(). Some other fixes are included that ensure the tests are working correctly as far as Oracle is concerned. Change-Id: I8ad8a5a33e6a70fcad235f6a7e82e91687b74fee Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
parent
239252d917
commit
693a399acb
@ -96,14 +96,26 @@ static QString qGetHostName()
|
||||
// to prevent nameclashes on our database server, each machine
|
||||
// will use its own set of table names. Call this function to get
|
||||
// "tablename_hostname"
|
||||
inline static QString qTableName( const QString& prefix, const char *sourceFileName )
|
||||
inline QString fixupTableName(const QString &tableName, QSqlDatabase db)
|
||||
{
|
||||
return QLatin1String("dbtst")+QString::number(qHash(QLatin1String(sourceFileName) + "_" + qGetHostName().replace( "-", "_" )), 16)+"_"+prefix;
|
||||
QString tbName = tableName;
|
||||
// On Oracle we are limited to 30 character tablenames
|
||||
QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
|
||||
if (d && d->dbmsType == QSqlDriverPrivate::Oracle)
|
||||
tbName.truncate(30);
|
||||
return tbName;
|
||||
}
|
||||
|
||||
inline static QString qTableName( const QString& prefix, QSqlDriver* driver )
|
||||
inline static QString qTableName(const QString& prefix, const char *sourceFileName, QSqlDatabase db)
|
||||
{
|
||||
return driver->escapeIdentifier( prefix + "_" + qGetHostName(), QSqlDriver::TableName );
|
||||
return fixupTableName(QString(QLatin1String("dbtst") + QString::number(qHash(QLatin1String(sourceFileName) +
|
||||
"_" + qGetHostName().replace( "-", "_" )), 16) + "_" + prefix), db);
|
||||
}
|
||||
|
||||
inline static QString qTableName(const QString& prefix, QSqlDatabase db)
|
||||
{
|
||||
return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + "_" + qGetHostName(), QSqlDriver::TableName)),
|
||||
db);
|
||||
}
|
||||
|
||||
inline static bool testWhiteSpaceNames( const QString &name )
|
||||
@ -467,6 +479,8 @@ public:
|
||||
{
|
||||
if (db.driverName().startsWith("QPSQL"))
|
||||
return QLatin1String("timestamp");
|
||||
if (db.driverName().startsWith("QOCI") && getOraVersion(db) >= 9)
|
||||
return QLatin1String("timestamp(0)");
|
||||
return QLatin1String("datetime");
|
||||
}
|
||||
|
||||
|
@ -242,10 +242,10 @@ struct FieldDef {
|
||||
// excluding the primary key field
|
||||
static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db)
|
||||
{
|
||||
tst_Databases::safeDropTable(db, qTableName("qtestfields", __FILE__));
|
||||
tst_Databases::safeDropTable(db, qTableName("qtestfields", __FILE__, db));
|
||||
QSqlQuery q(db);
|
||||
// construct a create table statement consisting of all fieldtypes
|
||||
QString qs = "create table " + qTableName("qtestfields", __FILE__);
|
||||
QString qs = "create table " + qTableName("qtestfields", __FILE__, db);
|
||||
QString autoName = tst_Databases::autoFieldName(db);
|
||||
if (tst_Databases::isMSAccess(db))
|
||||
qs.append(" (id int not null");
|
||||
@ -299,18 +299,18 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db)
|
||||
|
||||
// please never ever change this table; otherwise fix all tests ;)
|
||||
if (tst_Databases::isMSAccess(db)) {
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__) +
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__, db) +
|
||||
" (id int not null, t_varchar varchar(40) not null, t_char char(40), "
|
||||
"t_numeric number, primary key (id, t_varchar))"));
|
||||
} else {
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__) +
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__, db) +
|
||||
" (id integer not null, t_varchar varchar(40) not null, "
|
||||
"t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar))"));
|
||||
}
|
||||
|
||||
if (testWhiteSpaceNames(db.driverName())) {
|
||||
QString qry = "create table "
|
||||
+ db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName)
|
||||
+ db.driver()->escapeIdentifier(qTableName("qtest", __FILE__, db) + " test", QSqlDriver::TableName)
|
||||
+ '('
|
||||
+ db.driver()->escapeIdentifier(QLatin1String("test test"), QSqlDriver::FieldName)
|
||||
+ " int not null primary key)";
|
||||
@ -329,45 +329,45 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
|
||||
}
|
||||
|
||||
// drop the view first, otherwise we'll get dependency problems
|
||||
tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view", __FILE__) << qTableName("qtest_view2", __FILE__));
|
||||
tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view", __FILE__, db) << qTableName("qtest_view2", __FILE__, db));
|
||||
|
||||
QStringList tableNames;
|
||||
tableNames << qTableName("qtest", __FILE__)
|
||||
<< qTableName("qtestfields", __FILE__)
|
||||
<< qTableName("qtestalter", __FILE__)
|
||||
<< qTableName("qtest_temp", __FILE__)
|
||||
<< qTableName("qtest_bigint", __FILE__)
|
||||
<< qTableName("qtest_xmltype", __FILE__)
|
||||
<< qTableName("latin1table", __FILE__)
|
||||
<< qTableName("qtest_sqlguid", __FILE__)
|
||||
<< qTableName("batable", __FILE__)
|
||||
<< qTableName("qtest_prec", __FILE__)
|
||||
<< qTableName("uint", __FILE__)
|
||||
<< qTableName("strings", __FILE__)
|
||||
<< qTableName("numericfields", __FILE__)
|
||||
<< qTableName("qtest_ibaseblobs", __FILE__)
|
||||
<< qTableName("qtestBindBool", __FILE__)
|
||||
<< qTableName("testqGetString", __FILE__)
|
||||
<< qTableName("qtest_sqlguid", __FILE__)
|
||||
<< qTableName("uint_table", __FILE__)
|
||||
<< qTableName("uint_test", __FILE__)
|
||||
<< qTableName("bug_249059", __FILE__);
|
||||
tableNames << qTableName("qtest", __FILE__, db)
|
||||
<< qTableName("qtestfields", __FILE__, db)
|
||||
<< qTableName("qtestalter", __FILE__, db)
|
||||
<< qTableName("qtest_temp", __FILE__, db)
|
||||
<< qTableName("qtest_bigint", __FILE__, db)
|
||||
<< qTableName("qtest_xmltype", __FILE__, db)
|
||||
<< qTableName("latin1table", __FILE__, db)
|
||||
<< qTableName("qtest_sqlguid", __FILE__, db)
|
||||
<< qTableName("batable", __FILE__, db)
|
||||
<< qTableName("qtest_prec", __FILE__, db)
|
||||
<< qTableName("uint", __FILE__, db)
|
||||
<< qTableName("strings", __FILE__, db)
|
||||
<< qTableName("numericfields", __FILE__, db)
|
||||
<< qTableName("qtest_ibaseblobs", __FILE__, db)
|
||||
<< qTableName("qtestBindBool", __FILE__, db)
|
||||
<< qTableName("testqGetString", __FILE__, db)
|
||||
<< qTableName("qtest_sqlguid", __FILE__, db)
|
||||
<< qTableName("uint_table", __FILE__, db)
|
||||
<< qTableName("uint_test", __FILE__, db)
|
||||
<< qTableName("bug_249059", __FILE__, db);
|
||||
|
||||
QSqlQuery q(0, db);
|
||||
if (db.driverName().startsWith("QPSQL")) {
|
||||
q.exec("drop schema " + qTableName("qtestschema", __FILE__) + " cascade");
|
||||
q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__) + " cascade");
|
||||
q.exec("drop schema " + qTableName("qtestschema", __FILE__, db) + " cascade");
|
||||
q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__, db) + " cascade");
|
||||
}
|
||||
|
||||
if (testWhiteSpaceNames(db.driverName()))
|
||||
tableNames << db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName);
|
||||
tableNames << db.driver()->escapeIdentifier(qTableName("qtest", __FILE__, db) + " test", QSqlDriver::TableName);
|
||||
|
||||
tst_Databases::safeDropTables(db, tableNames);
|
||||
|
||||
if (db.driverName().startsWith("QOCI")) {
|
||||
q.exec("drop user "+qTableName("CREATOR", __FILE__)+" cascade");
|
||||
q.exec("drop user "+qTableName("APPUSER", __FILE__)+" cascade");
|
||||
q.exec("DROP TABLE system."+qTableName("mypassword", __FILE__));
|
||||
q.exec("drop user "+qTableName("CREATOR", __FILE__, db)+ " cascade");
|
||||
q.exec("drop user "+qTableName("APPUSER", __FILE__, db) + " cascade");
|
||||
q.exec("DROP TABLE sys."+qTableName("mypassword", __FILE__, db));
|
||||
|
||||
}
|
||||
}
|
||||
@ -377,7 +377,7 @@ void tst_QSqlDatabase::populateTestTables(QSqlDatabase db)
|
||||
if (!db.isValid())
|
||||
return;
|
||||
QSqlQuery q(db);
|
||||
const QString qtest(qTableName("qtest", __FILE__));
|
||||
const QString qtest(qTableName("qtest", __FILE__, db));
|
||||
|
||||
q.exec("delete from " + qtest); //non-fatal
|
||||
QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (0, 'VarChar0', 'Char0', 1.1)"));
|
||||
@ -502,7 +502,7 @@ void tst_QSqlDatabase::tables()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString qtest(qTableName("qtest", __FILE__)), qtest_view(qTableName("qtest_view", __FILE__)), temp_tab(qTableName("test_tab", __FILE__));
|
||||
const QString qtest(qTableName("qtest", __FILE__, db)), qtest_view(qTableName("qtest_view", __FILE__, db)), temp_tab(qTableName("test_tab", __FILE__, db));
|
||||
|
||||
bool views = true;
|
||||
bool tempTables = false;
|
||||
@ -567,7 +567,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
if (testWhiteSpaceNames(db.driverName())) {
|
||||
const QString tableName(qTableName("qtest", __FILE__) + " test");
|
||||
const QString tableName(qTableName("qtest", __FILE__, db) + " test");
|
||||
QVERIFY(db.tables().contains(tableName, Qt::CaseInsensitive));
|
||||
|
||||
QSqlRecord rec = db.record(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName));
|
||||
@ -595,7 +595,7 @@ void tst_QSqlDatabase::alterTable()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString qtestalter(qTableName("qtestalter", __FILE__));
|
||||
const QString qtestalter(qTableName("qtestalter", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
|
||||
@ -671,12 +671,12 @@ void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase
|
||||
{
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__));
|
||||
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__, db));
|
||||
QCOMPARE((int)rec.count(), fieldCount+1);
|
||||
testRecord(fieldDefs, rec, db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__, db)));
|
||||
}
|
||||
|
||||
void tst_QSqlDatabase::recordTDS()
|
||||
@ -772,12 +772,12 @@ void tst_QSqlDatabase::recordOCI()
|
||||
commonFieldTest(fieldDefs, db, fieldCount);
|
||||
|
||||
// some additional tests
|
||||
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__));
|
||||
QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__, db));
|
||||
QCOMPARE(rec.field("T_NUMBER").length(), 10);
|
||||
QCOMPARE(rec.field("T_NUMBER").precision(), 5);
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields", __FILE__, db)));
|
||||
rec = q.record();
|
||||
QCOMPARE(rec.field("T_NUMBER").length(), 10);
|
||||
QCOMPARE(rec.field("T_NUMBER").precision(), 5);
|
||||
@ -834,11 +834,11 @@ void tst_QSqlDatabase::recordPSQL()
|
||||
if(tst_Databases::isPostgreSQL(db))
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__) + "_t_bigserial_seq");
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__) + "_t_serial_seq");
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db) + "_t_bigserial_seq");
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db) + "_t_serial_seq");
|
||||
// older psql cut off the table name
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__).left(15) + "_t_bigserial_seq");
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__).left(18) + "_t_serial_seq");
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db).left(15) + "_t_bigserial_seq");
|
||||
q.exec("drop sequence " + qTableName("qtestfields", __FILE__, db).left(18) + "_t_serial_seq");
|
||||
|
||||
const int fieldCount = createFieldTable(fieldDefs, db);
|
||||
QVERIFY(fieldCount > 0);
|
||||
@ -1075,7 +1075,7 @@ void tst_QSqlDatabase::transaction()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString qtest(qTableName("qtest", __FILE__));
|
||||
const QString qtest(qTableName("qtest", __FILE__, db));
|
||||
|
||||
if (!db.driver()->hasFeature(QSqlDriver::Transactions))
|
||||
QSKIP("DBMS not transaction capable");
|
||||
@ -1125,7 +1125,7 @@ void tst_QSqlDatabase::bigIntField()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
QString drvName = db.driverName();
|
||||
const QString qtest_bigint(qTableName("qtest_bigint", __FILE__));
|
||||
const QString qtest_bigint(qTableName("qtest_bigint", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
q.setForwardOnly(true);
|
||||
@ -1196,21 +1196,21 @@ void tst_QSqlDatabase::caseSensivity()
|
||||
|| db.driverName().startsWith("QODBC"))
|
||||
cs = true;
|
||||
|
||||
QSqlRecord rec = db.record(qTableName("qtest", __FILE__));
|
||||
QSqlRecord rec = db.record(qTableName("qtest", __FILE__, db));
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
if (!cs) {
|
||||
rec = db.record(qTableName("QTEST", __FILE__).toUpper());
|
||||
rec = db.record(qTableName("QTEST", __FILE__, db).toUpper());
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
rec = db.record(qTableName("qTesT", __FILE__));
|
||||
rec = db.record(qTableName("qTesT", __FILE__, db));
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
}
|
||||
|
||||
rec = db.primaryIndex(qTableName("qtest", __FILE__));
|
||||
rec = db.primaryIndex(qTableName("qtest", __FILE__, db));
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
if (!cs) {
|
||||
rec = db.primaryIndex(qTableName("QTEST", __FILE__).toUpper());
|
||||
rec = db.primaryIndex(qTableName("QTEST", __FILE__, db).toUpper());
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
rec = db.primaryIndex(qTableName("qTesT", __FILE__));
|
||||
rec = db.primaryIndex(qTableName("qTesT", __FILE__, db));
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
}
|
||||
}
|
||||
@ -1226,7 +1226,7 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord()
|
||||
fieldname = fieldname.toUpper();
|
||||
|
||||
QSqlQuery q(db);
|
||||
QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest", __FILE__);
|
||||
QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest", __FILE__, db);
|
||||
QVERIFY_SQL(q, exec(query));
|
||||
QCOMPARE(q.record().fieldName(0), fieldname);
|
||||
}
|
||||
@ -1246,9 +1246,9 @@ void tst_QSqlDatabase::psql_schemas()
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
}
|
||||
|
||||
QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema", __FILE__, db)));
|
||||
|
||||
QString table = qTableName("qtestschema", __FILE__) + '.' + qTableName("qtesttable", __FILE__);
|
||||
QString table = qTableName("qtestschema", __FILE__, db) + '.' + qTableName("qtesttable", __FILE__, db);
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE " + table + " (id int primary key, name varchar(20))"));
|
||||
|
||||
QVERIFY(db.tables().contains(table));
|
||||
@ -1278,8 +1278,8 @@ void tst_QSqlDatabase::psql_escapedIdentifiers()
|
||||
if(tst_Databases::isPostgreSQL(db))
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
|
||||
const QString schemaName(qTableName("qtestScHeMa", __FILE__)),
|
||||
tableName(qTableName("qtest", __FILE__)),
|
||||
const QString schemaName(qTableName("qtestScHeMa", __FILE__, db)),
|
||||
tableName(qTableName("qtest", __FILE__, db)),
|
||||
field1Name(QLatin1String("fIeLdNaMe")),
|
||||
field2Name(QLatin1String("ZuLu"));
|
||||
|
||||
@ -1318,7 +1318,7 @@ void tst_QSqlDatabase::psql_escapeBytea()
|
||||
QByteArray ba(dta, 4);
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("batable", __FILE__));
|
||||
const QString tableName(qTableName("batable", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (ba bytea)").arg(tableName)));
|
||||
|
||||
QSqlQuery iq(db);
|
||||
@ -1351,7 +1351,7 @@ void tst_QSqlDatabase::bug_249059()
|
||||
QSKIP("Test requires PostgreSQL >= 7.3");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("bug_249059", __FILE__));
|
||||
const QString tableName(qTableName("bug_249059", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName)));
|
||||
|
||||
QSqlQuery iq(db);
|
||||
@ -1386,7 +1386,7 @@ void tst_QSqlDatabase::precisionPolicy()
|
||||
// DBMS_SPECIFIC(db, "QPSQL");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("qtest_prec", __FILE__));
|
||||
const QString tableName(qTableName("qtest_prec", __FILE__, db));
|
||||
if(!db.driver()->hasFeature(QSqlDriver::LowPrecisionNumbers))
|
||||
QSKIP("Driver or database doesn't support setting precision policy");
|
||||
|
||||
@ -1422,8 +1422,6 @@ void tst_QSqlDatabase::precisionPolicy()
|
||||
|
||||
q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt32);
|
||||
QVERIFY_SQL(q, exec(query));
|
||||
if(db.driverName().startsWith("QOCI"))
|
||||
QEXPECT_FAIL("", "Oracle fails to move to next when data columns are oversize", Abort);
|
||||
QVERIFY_SQL(q, next());
|
||||
if(db.driverName().startsWith("QSQLITE"))
|
||||
QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue);
|
||||
@ -1481,7 +1479,7 @@ void tst_QSqlDatabase::mysqlOdbc_unsignedIntegers()
|
||||
QSKIP("MySQL through ODBC-driver specific test");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("uint", __FILE__));
|
||||
const QString tableName(qTableName("uint", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (foo integer(10) unsigned, bar integer(10))").arg(tableName)));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (-4000000000, -4000000000)").arg(tableName)));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (4000000000, 4000000000)").arg(tableName)));
|
||||
@ -1505,7 +1503,7 @@ void tst_QSqlDatabase::accessOdbc_strings()
|
||||
QSKIP("MS Access specific test");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("strings", __FILE__));
|
||||
const QString tableName(qTableName("strings", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (aStr memo, bStr memo, cStr memo, dStr memo"
|
||||
", eStr memo, fStr memo, gStr memo, hStr memo)").arg(tableName)));
|
||||
|
||||
@ -1543,7 +1541,7 @@ void tst_QSqlDatabase::ibase_numericFields()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("numericfields", __FILE__));
|
||||
const QString tableName(qTableName("numericfields", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id int not null, num1 NUMERIC(2,1), "
|
||||
"num2 NUMERIC(5,2), num3 NUMERIC(10,3), "
|
||||
"num4 NUMERIC(18,4))").arg(tableName)));
|
||||
@ -1615,7 +1613,7 @@ void tst_QSqlDatabase::ibase_fetchBlobs()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString tableName(qTableName("qtest_ibaseblobs", __FILE__));
|
||||
const QString tableName(qTableName("qtest_ibaseblobs", __FILE__, db));
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (blob1 BLOB segment size 256)").arg(tableName)));
|
||||
|
||||
@ -1648,7 +1646,7 @@ void tst_QSqlDatabase::ibase_procWithoutReturnValues()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString procName(qTableName("qtest_proc1", __FILE__));
|
||||
const QString procName(qTableName("qtest_proc1", __FILE__, db));
|
||||
q.exec(QString("drop procedure %1").arg(procName));
|
||||
QVERIFY_SQL(q, exec("CREATE PROCEDURE " + procName + " (str VARCHAR(10))\nAS BEGIN\nstr='test';\nEND;"));
|
||||
QVERIFY_SQL(q, exec(QString("execute procedure %1('qtest')").arg(procName)));
|
||||
@ -1664,7 +1662,7 @@ void tst_QSqlDatabase::ibase_procWithReturnValues()
|
||||
if (!db.driverName().startsWith("QIBASE"))
|
||||
QSKIP("InterBase specific test");
|
||||
|
||||
const QString procName(qTableName("qtest_proc2", __FILE__));
|
||||
const QString procName(qTableName("qtest_proc2", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
q.exec(QString("drop procedure %1").arg(procName));
|
||||
@ -1706,11 +1704,11 @@ void tst_QSqlDatabase::formatValueTrimStrings()
|
||||
|
||||
QSqlQuery q(db);
|
||||
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest", __FILE__))));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest", __FILE__))));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest", __FILE__))));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest", __FILE__, db))));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest", __FILE__, db))));
|
||||
QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest", __FILE__, db))));
|
||||
|
||||
QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest", __FILE__))));
|
||||
QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest", __FILE__, db))));
|
||||
|
||||
QVERIFY_SQL(q, next());
|
||||
|
||||
@ -1734,10 +1732,10 @@ void tst_QSqlDatabase::odbc_reopenDatabase()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__, db)));
|
||||
QVERIFY_SQL(q, next());
|
||||
db.open();
|
||||
QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__, db)));
|
||||
QVERIFY_SQL(q, next());
|
||||
db.open();
|
||||
}
|
||||
@ -1752,10 +1750,10 @@ void tst_QSqlDatabase::odbc_bindBoolean()
|
||||
QSKIP("MySql has inconsistent behaviour of bit field type across versions.");
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool", __FILE__) + "(id int, boolvalue bit)"));
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool", __FILE__, db) + "(id int, boolvalue bit)"));
|
||||
|
||||
// Bind and insert
|
||||
QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool", __FILE__) + " VALUES(?, ?)"));
|
||||
QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool", __FILE__, db) + " VALUES(?, ?)"));
|
||||
q.bindValue(0, 1);
|
||||
q.bindValue(1, true);
|
||||
QVERIFY_SQL(q, exec());
|
||||
@ -1764,7 +1762,7 @@ void tst_QSqlDatabase::odbc_bindBoolean()
|
||||
QVERIFY_SQL(q, exec());
|
||||
|
||||
// Retrive
|
||||
QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool", __FILE__) + " ORDER BY id"));
|
||||
QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool", __FILE__, db) + " ORDER BY id"));
|
||||
QVERIFY_SQL(q, next());
|
||||
QCOMPARE(q.value(0).toInt(), 1);
|
||||
QCOMPARE(q.value(1).toBool(), true);
|
||||
@ -1778,7 +1776,7 @@ void tst_QSqlDatabase::odbc_testqGetString()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString testqGetString(qTableName("testqGetString", __FILE__));
|
||||
const QString testqGetString(qTableName("testqGetString", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
if (tst_Databases::isSqlServer(db))
|
||||
@ -1822,7 +1820,7 @@ void tst_QSqlDatabase::mysql_multiselect()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString qtest(qTableName("qtest", __FILE__));
|
||||
const QString qtest(qTableName("qtest", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
QString version=tst_Databases::getMySqlVersion( db );
|
||||
@ -1848,7 +1846,7 @@ void tst_QSqlDatabase::ibase_useCustomCharset()
|
||||
db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1");
|
||||
db.open();
|
||||
|
||||
const QString tableName(qTableName("latin1table", __FILE__));
|
||||
const QString tableName(qTableName("latin1table", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(text VARCHAR(6) CHARACTER SET Latin1)").arg(tableName)));
|
||||
@ -1886,8 +1884,8 @@ void tst_QSqlDatabase::oci_xmltypeSupport()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString tableName(qTableName("qtest_xmltype", __FILE__));
|
||||
QString xml("<?xml version=\"1.0\"?><TABLE_NAME>MY_TABLE</TABLE_NAME>");
|
||||
const QString tableName(qTableName("qtest_xmltype", __FILE__, db));
|
||||
QString xml("<?xml version=\"1.0\"?>\n<TABLE_NAME>MY_TABLE</TABLE_NAME>\n");
|
||||
QSqlQuery q(db);
|
||||
|
||||
// Embedding the XML in the statement
|
||||
@ -1914,7 +1912,7 @@ void tst_QSqlDatabase::oci_fieldLength()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString tableName(qTableName("qtest", __FILE__));
|
||||
const QString tableName(qTableName("qtest", __FILE__, db));
|
||||
QSqlQuery q(db);
|
||||
|
||||
QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1").arg(tableName)));
|
||||
@ -1930,7 +1928,7 @@ void tst_QSqlDatabase::oci_synonymstest()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString creator(qTableName("CREATOR", __FILE__)), appuser(qTableName("APPUSER", __FILE__)), table1(qTableName("TABLE1", __FILE__));
|
||||
const QString creator(qTableName("CREATOR", __FILE__, db)), appuser(qTableName("APPUSER", __FILE__, db)), table1(qTableName("TABLE1", __FILE__, db));
|
||||
// QVERIFY_SQL(q, exec("drop public synonym "+table1));
|
||||
QVERIFY_SQL(q, exec(QString("create user %1 identified by %2 default tablespace users temporary tablespace temp").arg(creator).arg(creator)));
|
||||
QVERIFY_SQL(q, exec(QString("grant CONNECT to %1").arg(creator)));
|
||||
@ -1948,8 +1946,8 @@ void tst_QSqlDatabase::oci_synonymstest()
|
||||
db3.close();
|
||||
QVERIFY_SQL(db3, open(appuser,appuser));
|
||||
QSqlQuery q3(db3);
|
||||
QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms", __FILE__)+" for "+creator+'.'+table1));
|
||||
QVERIFY_SQL(db3, tables().filter(qTableName("synonyms", __FILE__), Qt::CaseInsensitive).count() >= 1);
|
||||
QVERIFY_SQL(q3, exec("create synonym " + appuser + '.' + qTableName("synonyms", __FILE__, db) + " for " + creator + '.' + table1));
|
||||
QVERIFY_SQL(db3, tables().filter(qTableName("synonyms", __FILE__, db), Qt::CaseInsensitive).count() >= 1);
|
||||
}
|
||||
|
||||
|
||||
@ -1963,7 +1961,7 @@ void tst_QSqlDatabase::odbc_uniqueidentifier()
|
||||
if (!tst_Databases::isSqlServer(db))
|
||||
QSKIP("SQL Server (ODBC) specific test");
|
||||
|
||||
const QString tableName(qTableName("qtest_sqlguid", __FILE__));
|
||||
const QString tableName(qTableName("qtest_sqlguid", __FILE__, db));
|
||||
QString guid = QString("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE");
|
||||
QString invalidGuid = QString("GAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE");
|
||||
|
||||
@ -2006,7 +2004,7 @@ void tst_QSqlDatabase::odbc_uintfield()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString tableName(qTableName("uint_table", __FILE__));
|
||||
const QString tableName(qTableName("uint_table", __FILE__, db));
|
||||
unsigned int val = 4294967295U;
|
||||
|
||||
QSqlQuery q(db);
|
||||
@ -2070,7 +2068,7 @@ void tst_QSqlDatabase::eventNotificationIBase()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString procedureName(qTableName("posteventProc", __FILE__));
|
||||
const QString procedureName(qTableName("posteventProc", __FILE__, db));
|
||||
QSqlDriver *driver=db.driver();
|
||||
QVERIFY_SQL(*driver, subscribeToNotification(procedureName));
|
||||
QTest::qWait(300); // Interbase needs some time to call the driver callback.
|
||||
@ -2100,7 +2098,7 @@ void tst_QSqlDatabase::eventNotificationPSQL()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQuery query(db);
|
||||
QString procedureName = qTableName("posteventProc", __FILE__);
|
||||
QString procedureName = qTableName("posteventProc", __FILE__, db);
|
||||
QString payload = "payload";
|
||||
QSqlDriver &driver=*(db.driver());
|
||||
QVERIFY_SQL(driver, subscribeToNotification(procedureName));
|
||||
@ -2124,7 +2122,7 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt()
|
||||
QSKIP("SQLite3 specific test");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("uint_test", __FILE__));
|
||||
const QString tableName(qTableName("uint_test", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(uint_field UNSIGNED INTEGER)").arg(tableName)));
|
||||
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName)));
|
||||
q.addBindValue(4000000000U);
|
||||
@ -2144,7 +2142,7 @@ void tst_QSqlDatabase::db2_valueCacheUpdate()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const QString tableName(qTableName("qtest", __FILE__));
|
||||
const QString tableName(qTableName("qtest", __FILE__, db));
|
||||
QSqlQuery q(db);
|
||||
q.exec(QString("SELECT id, t_varchar, t_char, t_numeric FROM %1").arg(tableName));
|
||||
q.next();
|
||||
@ -2167,7 +2165,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093()
|
||||
|
||||
// select a record with NULL value
|
||||
QSqlQuery q(QString::null, db);
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__) + " where id = 4"));
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__, db) + " where id = 4"));
|
||||
QVERIFY_SQL(q, next());
|
||||
|
||||
QSqlDriver *driver = db.driver();
|
||||
@ -2190,17 +2188,18 @@ void tst_QSqlDatabase::mysql_savepointtest()
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("begin"));
|
||||
QVERIFY_SQL(q, exec("insert into "+qTableName("qtest", __FILE__)+" VALUES (54, 'foo', 'foo', 54.54)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest", __FILE__, db) + " VALUES (54, 'foo', 'foo', 54.54)"));
|
||||
QVERIFY_SQL(q, exec("savepoint foo"));
|
||||
}
|
||||
|
||||
void tst_QSqlDatabase::oci_tables()
|
||||
{
|
||||
QSKIP("Requires specific permissions to create a system table");
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
QSqlQuery q(db);
|
||||
const QString systemTableName("system."+qTableName("mypassword", __FILE__));
|
||||
const QString systemTableName("sys." + qTableName("mypassword", __FILE__, db).toUpper());
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))"));
|
||||
QVERIFY(!db.tables().contains(systemTableName.toUpper()));
|
||||
QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper()));
|
||||
@ -2220,8 +2219,8 @@ void tst_QSqlDatabase::sqlite_enable_cache_mode()
|
||||
db2.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
|
||||
QVERIFY_SQL(db2, open());
|
||||
QSqlQuery q(db), q2(db2);
|
||||
QVERIFY_SQL(q, exec("select * from "+qTableName("qtest", __FILE__)));
|
||||
QVERIFY_SQL(q2, exec("select * from "+qTableName("qtest", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__, db)));
|
||||
QVERIFY_SQL(q2, exec("select * from " + qTableName("qtest", __FILE__, db)));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QSqlDatabase)
|
||||
|
@ -77,7 +77,7 @@ void tst_QSqlDriver::initTestCase_data()
|
||||
void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
|
||||
{
|
||||
QSqlQuery q(db);
|
||||
const QString relTEST1(qTableName("relTEST1", __FILE__));
|
||||
const QString relTEST1(qTableName("relTEST1", __FILE__, db));
|
||||
|
||||
if(tst_Databases::isPostgreSQL(db))
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
@ -102,7 +102,7 @@ void tst_QSqlDriver::cleanupTestCase()
|
||||
{
|
||||
foreach (const QString &dbName, dbs.dbNames) {
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
tst_Databases::safeDropTable( db, qTableName( "relTEST1", __FILE__ ) );
|
||||
tst_Databases::safeDropTable(db, qTableName("relTEST1", __FILE__, db));
|
||||
}
|
||||
dbs.close();
|
||||
}
|
||||
@ -121,7 +121,7 @@ void tst_QSqlDriver::record()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tablename(qTableName("relTEST1", __FILE__));
|
||||
QString tablename(qTableName("relTEST1", __FILE__, db));
|
||||
QStringList fields;
|
||||
fields << "id" << "name" << "title_key" << "another_title_key";
|
||||
|
||||
@ -178,7 +178,7 @@ void tst_QSqlDriver::primaryIndex()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tablename(qTableName("relTEST1", __FILE__));
|
||||
QString tablename(qTableName("relTEST1", __FILE__, db));
|
||||
//check that we can get primary index using unquoted mixed case table name
|
||||
QSqlIndex index = db.driver()->primaryIndex(tablename);
|
||||
QCOMPARE(index.count(), 1);
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
#include "../qsqldatabase/tst_databases.h"
|
||||
|
||||
const QString qtest(qTableName( "qtest", __FILE__ ));
|
||||
const QString qtest(qTableName("qtest", __FILE__, QSqlDatabase()));
|
||||
|
||||
class tst_QSqlQuery : public QObject
|
||||
{
|
||||
@ -318,59 +318,59 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
|
||||
QStringList tablenames;
|
||||
// drop all the table in case a testcase failed
|
||||
tablenames << qtest
|
||||
<< qTableName( "qtest_null", __FILE__ )
|
||||
<< qTableName( "qtest_blob", __FILE__ )
|
||||
<< qTableName( "qtest_bittest", __FILE__ )
|
||||
<< qTableName( "qtest_nullblob", __FILE__ )
|
||||
<< qTableName( "qtest_rawtest", __FILE__ )
|
||||
<< qTableName( "qtest_precision", __FILE__ )
|
||||
<< qTableName( "qtest_prepare", __FILE__ )
|
||||
<< qTableName( "qtestj1", __FILE__ )
|
||||
<< qTableName( "qtestj2", __FILE__ )
|
||||
<< qTableName( "char1Select", __FILE__ )
|
||||
<< qTableName( "char1SU", __FILE__ )
|
||||
<< qTableName( "qxmltest", __FILE__ )
|
||||
<< qTableName( "qtest_exerr", __FILE__ )
|
||||
<< qTableName( "qtest_empty", __FILE__ )
|
||||
<< qTableName( "clobby", __FILE__ )
|
||||
<< qTableName( "bindtest", __FILE__ )
|
||||
<< qTableName( "more_results", __FILE__ )
|
||||
<< qTableName( "blobstest", __FILE__ )
|
||||
<< qTableName( "oraRowId", __FILE__ )
|
||||
<< qTableName( "qtest_batch", __FILE__ )
|
||||
<< qTableName("bug6421", __FILE__).toUpper()
|
||||
<< qTableName("bug5765", __FILE__)
|
||||
<< qTableName("bug6852", __FILE__)
|
||||
<< qTableName("bug21884", __FILE__)
|
||||
<< qTableName("bug23895", __FILE__)
|
||||
<< qTableName( "qtest_lockedtable", __FILE__ )
|
||||
<< qTableName( "Planet", __FILE__ )
|
||||
<< qTableName( "task_250026", __FILE__ )
|
||||
<< qTableName( "task_234422", __FILE__ )
|
||||
<< qTableName("test141895", __FILE__)
|
||||
<< qTableName("qtest_oraOCINumber", __FILE__)
|
||||
<< qTableName( "bug2192", __FILE__);
|
||||
<< qTableName("qtest_null", __FILE__, db)
|
||||
<< qTableName("qtest_blob", __FILE__, db)
|
||||
<< qTableName("qtest_bittest", __FILE__, db)
|
||||
<< qTableName("qtest_nullblob", __FILE__, db)
|
||||
<< qTableName("qtest_rawtest", __FILE__, db)
|
||||
<< qTableName("qtest_precision", __FILE__, db)
|
||||
<< qTableName("qtest_prepare", __FILE__, db)
|
||||
<< qTableName("qtestj1", __FILE__, db)
|
||||
<< qTableName("qtestj2", __FILE__, db)
|
||||
<< qTableName("char1Select", __FILE__, db)
|
||||
<< qTableName("char1SU", __FILE__, db)
|
||||
<< qTableName("qxmltest", __FILE__, db)
|
||||
<< qTableName("qtest_exerr", __FILE__, db)
|
||||
<< qTableName("qtest_empty", __FILE__, db)
|
||||
<< qTableName("clobby", __FILE__, db)
|
||||
<< qTableName("bindtest", __FILE__, db)
|
||||
<< qTableName("more_results", __FILE__, db)
|
||||
<< qTableName("blobstest", __FILE__, db)
|
||||
<< qTableName("oraRowId", __FILE__, db)
|
||||
<< qTableName("qtest_batch", __FILE__, db)
|
||||
<< qTableName("bug6421", __FILE__, db).toUpper()
|
||||
<< qTableName("bug5765", __FILE__, db)
|
||||
<< qTableName("bug6852", __FILE__, db)
|
||||
<< qTableName("bug21884", __FILE__, db)
|
||||
<< qTableName("bug23895", __FILE__, db)
|
||||
<< qTableName("qtest_lockedtable", __FILE__, db)
|
||||
<< qTableName("Planet", __FILE__, db)
|
||||
<< qTableName("task_250026", __FILE__, db)
|
||||
<< qTableName("task_234422", __FILE__, db)
|
||||
<< qTableName("test141895", __FILE__, db)
|
||||
<< qTableName("qtest_oraOCINumber", __FILE__, db)
|
||||
<< qTableName("bug2192", __FILE__, db);
|
||||
|
||||
if ( db.driverName().startsWith("QPSQL") )
|
||||
tablenames << qTableName("task_233829", __FILE__);
|
||||
tablenames << qTableName("task_233829", __FILE__, db);
|
||||
|
||||
if ( db.driverName().startsWith("QSQLITE") )
|
||||
tablenames << qTableName( "record_sqlite", __FILE__ );
|
||||
tablenames << qTableName("record_sqlite", __FILE__, db);
|
||||
|
||||
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) )
|
||||
tablenames << qTableName( "qtest_longstr", __FILE__ );
|
||||
tablenames << qTableName("qtest_longstr", __FILE__, db);
|
||||
|
||||
if (tst_Databases::isSqlServer( db ))
|
||||
db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__));
|
||||
db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db));
|
||||
|
||||
if (tst_Databases::isMySQL( db ))
|
||||
db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__));
|
||||
db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__, db));
|
||||
|
||||
tst_Databases::safeDropTables( db, tablenames );
|
||||
|
||||
if ( db.driverName().startsWith( "QOCI" ) ) {
|
||||
QSqlQuery q( db );
|
||||
q.exec( "DROP PACKAGE " + qTableName("pkg", __FILE__) );
|
||||
q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db));
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,15 +391,15 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db )
|
||||
QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) );
|
||||
|
||||
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
|
||||
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int null, t_varchar varchar(20) null)" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int null, t_varchar varchar(20) null)"));
|
||||
else
|
||||
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int, t_varchar varchar(20))" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int, t_varchar varchar(20))"));
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::populateTestTables( QSqlDatabase db )
|
||||
{
|
||||
QSqlQuery q( db );
|
||||
const QString qtest_null(qTableName( "qtest_null", __FILE__ ));
|
||||
const QString qtest_null(qTableName( "qtest_null", __FILE__, db));
|
||||
q.exec( "delete from " + qtest );
|
||||
QVERIFY_SQL( q, exec( "insert into " + qtest + " values (1, 'VarChar1', 'Char1')" ) );
|
||||
QVERIFY_SQL( q, exec( "insert into " + qtest + " values (2, 'VarChar2', 'Char2')" ) );
|
||||
@ -423,7 +423,7 @@ void tst_QSqlQuery::char1Select()
|
||||
|
||||
{
|
||||
QSqlQuery q( db );
|
||||
const QString tbl = qTableName("char1Select", __FILE__);
|
||||
const QString tbl = qTableName("char1Select", __FILE__, db);
|
||||
q.exec( "drop table " + tbl);
|
||||
QVERIFY_SQL(q, exec("create table " + tbl + " (id char(1))"));
|
||||
QVERIFY_SQL(q, exec("insert into " + tbl + " values ('a')"));
|
||||
@ -456,7 +456,7 @@ void tst_QSqlQuery::char1SelectUnicode()
|
||||
QSKIP( "Test requires MySQL >= 5.0");
|
||||
|
||||
QString createQuery;
|
||||
const QString char1SelectUnicode(qTableName( "char1SU", __FILE__ ));
|
||||
const QString char1SelectUnicode(qTableName("char1SU", __FILE__, db));
|
||||
|
||||
if ( tst_Databases::isSqlServer( db ) )
|
||||
createQuery = "create table " + char1SelectUnicode + "(id nchar(1))";
|
||||
@ -501,7 +501,7 @@ void tst_QSqlQuery::oraRowId()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString oraRowId(qTableName("oraRowId", __FILE__));
|
||||
const QString oraRowId(qTableName("oraRowId", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
QVERIFY_SQL( q, exec( "select rowid from " + qtest ) );
|
||||
@ -536,7 +536,7 @@ void tst_QSqlQuery::mysqlOutValues()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString hello(qTableName( "hello", __FILE__ )), qtestproc(qTableName( "qtestproc", __FILE__ ));
|
||||
const QString hello(qTableName("hello", __FILE__, db)), qtestproc(qTableName("qtestproc", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
@ -594,7 +594,7 @@ void tst_QSqlQuery::bindBool()
|
||||
CHECK_DATABASE( db );
|
||||
QSqlQuery q(db);
|
||||
|
||||
const QString tableName(qTableName( "bindBool", __FILE__ ));
|
||||
const QString tableName(qTableName("bindBool", __FILE__, db));
|
||||
q.exec("DROP TABLE " + tableName);
|
||||
QString colType = db.driverName().startsWith("QPSQL") ? QLatin1String("BOOLEAN") : QLatin1String("INT");
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INT, flag " + colType + " NOT NULL, PRIMARY KEY(id))"));
|
||||
@ -622,7 +622,7 @@ void tst_QSqlQuery::oraOutValues()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString tst_outValues(qTableName("tst_outValues", __FILE__));
|
||||
const QString tst_outValues(qTableName("tst_outValues", __FILE__, db));
|
||||
|
||||
if ( !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
|
||||
QSKIP( "Test requires prepared query support");
|
||||
@ -718,7 +718,7 @@ void tst_QSqlQuery::oraClob()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString clobby(qTableName("clobby", __FILE__));
|
||||
const QString clobby(qTableName("clobby", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
@ -771,16 +771,16 @@ void tst_QSqlQuery::storedProceduresIBase()
|
||||
CHECK_DATABASE( db );
|
||||
|
||||
QSqlQuery q( db );
|
||||
q.exec( "drop procedure " + qTableName( "TESTPROC", __FILE__ ) );
|
||||
q.exec("drop procedure " + qTableName("TESTPROC", __FILE__, db));
|
||||
|
||||
QVERIFY_SQL( q, exec( "create procedure " + qTableName( "TESTPROC", __FILE__ ) +
|
||||
QVERIFY_SQL(q, exec("create procedure " + qTableName("TESTPROC", __FILE__, db) +
|
||||
" RETURNS (x integer, y varchar(20)) "
|
||||
"AS BEGIN "
|
||||
" x = 42; "
|
||||
" y = 'Hello Anders'; "
|
||||
"END" ) );
|
||||
|
||||
QVERIFY_SQL( q, prepare( "execute procedure " + qTableName( "TestProc", __FILE__ ) ) );
|
||||
QVERIFY_SQL(q, prepare("execute procedure " + qTableName("TestProc", __FILE__, db)));
|
||||
QVERIFY_SQL( q, exec() );
|
||||
|
||||
// check for a valid result set
|
||||
@ -797,7 +797,7 @@ void tst_QSqlQuery::storedProceduresIBase()
|
||||
// the second next shall fail
|
||||
QVERIFY( !q.next() );
|
||||
|
||||
q.exec( "drop procedure " + qTableName( "TestProc", __FILE__ ) );
|
||||
q.exec("drop procedure " + qTableName("TestProc", __FILE__, db));
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::outValuesDB2()
|
||||
@ -813,8 +813,8 @@ void tst_QSqlQuery::outValuesDB2()
|
||||
|
||||
q.setForwardOnly( true );
|
||||
|
||||
q.exec( "drop procedure " + qTableName( "tst_outValues", __FILE__ ) ); //non-fatal
|
||||
QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues", __FILE__ ) +
|
||||
q.exec("drop procedure " + qTableName("tst_outValues", __FILE__, db)); //non-fatal
|
||||
QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName("tst_outValues", __FILE__, db) +
|
||||
" (OUT x int, OUT x2 double, OUT x3 char(20))\n"
|
||||
"LANGUAGE SQL\n"
|
||||
"P1: BEGIN\n"
|
||||
@ -823,7 +823,7 @@ void tst_QSqlQuery::outValuesDB2()
|
||||
" SET x3 = 'Homer';\n"
|
||||
"END P1" ) );
|
||||
|
||||
QVERIFY_SQL( q, prepare( "call " + qTableName( "tst_outValues", __FILE__ ) + "(?, ?, ?)" ) );
|
||||
QVERIFY_SQL(q, prepare("call " + qTableName("tst_outValues", __FILE__, db) + "(?, ?, ?)"));
|
||||
|
||||
q.addBindValue( 0, QSql::Out );
|
||||
q.addBindValue( 0.0, QSql::Out );
|
||||
@ -841,7 +841,7 @@ void tst_QSqlQuery::outValues()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString tst_outValues(qTableName("tst_outValues", __FILE__));
|
||||
const QString tst_outValues(qTableName("tst_outValues", __FILE__, db));
|
||||
|
||||
if ( !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
|
||||
QSKIP( "Test requires prepared query support");
|
||||
@ -905,11 +905,11 @@ void tst_QSqlQuery::blob()
|
||||
|
||||
q.setForwardOnly( true );
|
||||
|
||||
QString queryString = QString( "create table " + qTableName( "qtest_blob", __FILE__ ) +
|
||||
QString queryString = QString("create table " + qTableName("qtest_blob", __FILE__, db) +
|
||||
" (id int not null primary key, t_blob %1)" ).arg( tst_Databases::blobTypeName( db, BLOBSIZE ) );
|
||||
QVERIFY_SQL( q, exec( queryString ) );
|
||||
|
||||
QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_blob", __FILE__ ) + " (id, t_blob) values (?, ?)" ) );
|
||||
QVERIFY_SQL(q, prepare("insert into " + qTableName("qtest_blob", __FILE__, db) + " (id, t_blob) values (?, ?)"));
|
||||
|
||||
for ( i = 0; i < BLOBCOUNT; ++i ) {
|
||||
q.addBindValue( i );
|
||||
@ -917,7 +917,7 @@ void tst_QSqlQuery::blob()
|
||||
QVERIFY_SQL( q, exec() );
|
||||
}
|
||||
|
||||
QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_blob", __FILE__ ) ) );
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest_blob", __FILE__, db)));
|
||||
|
||||
for ( i = 0; i < BLOBCOUNT; ++i ) {
|
||||
QVERIFY( q.next() );
|
||||
@ -1382,7 +1382,7 @@ void tst_QSqlQuery::isNull()
|
||||
CHECK_DATABASE( db );
|
||||
|
||||
QSqlQuery q( db );
|
||||
QVERIFY_SQL( q, exec( "select id, t_varchar from " + qTableName( "qtest_null", __FILE__ ) + " order by id" ) );
|
||||
QVERIFY_SQL(q, exec("select id, t_varchar from " + qTableName("qtest_null", __FILE__, db) + " order by id"));
|
||||
QVERIFY( q.next() );
|
||||
QVERIFY( !q.isNull( 0 ) );
|
||||
QVERIFY( q.isNull( 1 ) );
|
||||
@ -1408,13 +1408,13 @@ void tst_QSqlQuery::bitField()
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_bittest", __FILE__ ) + " (bitty bit)" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bittest", __FILE__, db) + " (bitty bit)"));
|
||||
|
||||
QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest", __FILE__ ) + " values (0)" ) );
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest_bittest", __FILE__, db) + " values (0)"));
|
||||
|
||||
QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest", __FILE__ ) + " values (1)" ) );
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest_bittest", __FILE__, db) + " values (1)"));
|
||||
|
||||
QVERIFY_SQL( q, exec( "select bitty from " + qTableName( "qtest_bittest", __FILE__ ) ) );
|
||||
QVERIFY_SQL(q, exec("select bitty from " + qTableName("qtest_bittest", __FILE__, db)));
|
||||
|
||||
QVERIFY( q.next() );
|
||||
|
||||
@ -1432,7 +1432,7 @@ void tst_QSqlQuery::nullBlob()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString qtest_nullblob(qTableName("qtest_nullblob", __FILE__));
|
||||
const QString qtest_nullblob(qTableName("qtest_nullblob", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
QVERIFY_SQL( q, exec( "create table " + qtest_nullblob + " (id int primary key, bb blob)" ) );
|
||||
@ -1462,7 +1462,7 @@ void tst_QSqlQuery::rawField()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString qtest_rawtest(qTableName("qtest_rawtest", __FILE__));
|
||||
const QString qtest_rawtest(qTableName("qtest_rawtest", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
q.setForwardOnly( true );
|
||||
@ -1487,7 +1487,7 @@ void tst_QSqlQuery::precision()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString qtest_precision(qTableName( "qtest_precision", __FILE__ ));
|
||||
const QString qtest_precision(qTableName("qtest_precision", __FILE__, db));
|
||||
|
||||
static const char* precStr = "1.2345678901234567891";
|
||||
|
||||
@ -1646,7 +1646,7 @@ void tst_QSqlQuery::joins()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString qtestj1(qTableName("qtestj1", __FILE__)), qtestj2(qTableName("qtestj2", __FILE__));
|
||||
const QString qtestj1(qTableName("qtestj1", __FILE__, db)), qtestj2(qTableName("qtestj2", __FILE__, db));
|
||||
|
||||
if ( db.driverName().startsWith( "QOCI" )
|
||||
|| db.driverName().startsWith( "QTDS" )
|
||||
@ -1731,7 +1731,7 @@ void tst_QSqlQuery::prepare_bind_exec()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString qtest_prepare(qTableName("qtest_prepare", __FILE__));
|
||||
const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db));
|
||||
|
||||
if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb"))
|
||||
QSKIP("Can't transliterate extended unicode to ascii");
|
||||
@ -2031,9 +2031,9 @@ void tst_QSqlQuery::sqlServerLongStrings()
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
QVERIFY_SQL( q, exec( "CREATE TABLE " + qTableName( "qtest_longstr", __FILE__ ) + " (id int primary key, longstring ntext)" ) );
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtest_longstr", __FILE__, db) + " (id int primary key, longstring ntext)"));
|
||||
|
||||
QVERIFY_SQL( q, prepare( "INSERT INTO " + qTableName( "qtest_longstr", __FILE__ ) + " VALUES (?, ?)" ) );
|
||||
QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtest_longstr", __FILE__, db) + " VALUES (?, ?)"));
|
||||
|
||||
q.addBindValue( 0 );
|
||||
|
||||
@ -2051,7 +2051,7 @@ void tst_QSqlQuery::sqlServerLongStrings()
|
||||
|
||||
QVERIFY_SQL( q, exec() );
|
||||
|
||||
QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_longstr", __FILE__ ) ) );
|
||||
QVERIFY_SQL(q, exec("select * from " + qTableName( "qtest_longstr", __FILE__, db)));
|
||||
|
||||
QVERIFY_SQL( q, next() );
|
||||
|
||||
@ -2103,7 +2103,7 @@ void tst_QSqlQuery::batchExec()
|
||||
QSKIP( "Database can't do BatchOperations");
|
||||
|
||||
QSqlQuery q( db );
|
||||
const QString tableName = qTableName( "qtest_batch", __FILE__ );
|
||||
const QString tableName = qTableName("qtest_batch", __FILE__, db);
|
||||
|
||||
QVERIFY_SQL( q, exec( "create table " + tableName + " (id int, name varchar(20), dt date, num numeric(8, 4))" ) );
|
||||
QVERIFY_SQL( q, prepare( "insert into " + tableName + " (id, name, dt, num) values (?, ?, ?, ?)" ) );
|
||||
@ -2247,9 +2247,9 @@ void tst_QSqlQuery::record_sqlite()
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
QVERIFY_SQL( q, exec( "create table "+qTableName( "record_sqlite", __FILE__ )+"(id integer primary key, name varchar, title int)" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("record_sqlite", __FILE__, db) + "(id integer primary key, name varchar, title int)"));
|
||||
|
||||
QSqlRecord rec = db.record( qTableName( "record_sqlite", __FILE__ ) );
|
||||
QSqlRecord rec = db.record(qTableName("record_sqlite", __FILE__, db));
|
||||
|
||||
QCOMPARE( rec.count(), 3 );
|
||||
QCOMPARE( rec.field( 0 ).type(), QVariant::Int );
|
||||
@ -2257,7 +2257,7 @@ void tst_QSqlQuery::record_sqlite()
|
||||
QCOMPARE( rec.field( 2 ).type(), QVariant::Int );
|
||||
|
||||
/* important - select from an empty table */
|
||||
QVERIFY_SQL( q, exec( "select id, name, title from "+qTableName( "record_sqlite", __FILE__ ) ) );
|
||||
QVERIFY_SQL(q, exec("select id, name, title from " + qTableName("record_sqlite", __FILE__, db)));
|
||||
|
||||
rec = q.record();
|
||||
QCOMPARE( rec.count(), 3 );
|
||||
@ -2276,13 +2276,13 @@ void tst_QSqlQuery::oraLong()
|
||||
|
||||
QString aLotOfText( 127000, QLatin1Char( 'H' ) );
|
||||
|
||||
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_longstr", __FILE__ ) + " (id int primary key, astr long)" ) );
|
||||
QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_longstr", __FILE__ ) + " (id, astr) values (?, ?)" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_longstr", __FILE__, db) + " (id int primary key, astr long)"));
|
||||
QVERIFY_SQL(q, prepare("insert into " + qTableName("qtest_longstr", __FILE__, db) + " (id, astr) values (?, ?)"));
|
||||
q.addBindValue( 1 );
|
||||
q.addBindValue( aLotOfText );
|
||||
QVERIFY_SQL( q, exec() );
|
||||
|
||||
QVERIFY_SQL( q, exec( "select id,astr from " + qTableName( "qtest_longstr", __FILE__ ) ) );
|
||||
QVERIFY_SQL(q, exec("select id,astr from " + qTableName("qtest_longstr", __FILE__, db)));
|
||||
|
||||
QVERIFY( q.next() );
|
||||
QCOMPARE( q.value( 0 ).toInt(), 1 );
|
||||
@ -2297,7 +2297,7 @@ void tst_QSqlQuery::execErrorRecovery()
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
const QString tbl = qTableName("qtest_exerr", __FILE__);
|
||||
const QString tbl = qTableName("qtest_exerr", __FILE__, db);
|
||||
q.exec("drop table " + tbl);
|
||||
QVERIFY_SQL(q, exec("create table " + tbl + " (id int not null primary key)"));
|
||||
QVERIFY_SQL(q, prepare("insert into " + tbl + " values (?)" ));
|
||||
@ -2354,7 +2354,7 @@ void tst_QSqlQuery::bindWithDoubleColonCastOperator()
|
||||
if ( !db.driverName().startsWith( "QPSQL" ) )
|
||||
QSKIP( "Test requires PostgreSQL");
|
||||
|
||||
const QString tablename(qTableName( "bindtest", __FILE__ ));
|
||||
const QString tablename(qTableName("bindtest", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
@ -2516,7 +2516,7 @@ void tst_QSqlQuery::sqlite_finish()
|
||||
db2.setDatabaseName( db.databaseName() );
|
||||
QVERIFY_SQL( db2, open() );
|
||||
|
||||
const QString tableName(qTableName( "qtest_lockedtable", __FILE__ ));
|
||||
const QString tableName(qTableName("qtest_lockedtable", __FILE__, db));
|
||||
QSqlQuery q( db );
|
||||
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
@ -2566,7 +2566,7 @@ void tst_QSqlQuery::nextResult()
|
||||
else if ( db.driverName().startsWith( "QDB2" ) )
|
||||
driverType = DB2;
|
||||
|
||||
const QString tableName(qTableName( "more_results", __FILE__ ));
|
||||
const QString tableName(qTableName("more_results", __FILE__, db));
|
||||
|
||||
QVERIFY_SQL( q, exec( "CREATE TABLE " + tableName + " (id integer, text varchar(20), num numeric(6, 3), empty varchar(10));" ) );
|
||||
|
||||
@ -2670,7 +2670,7 @@ void tst_QSqlQuery::nextResult()
|
||||
}
|
||||
|
||||
// Stored procedure with multiple result sets
|
||||
const QString procName(qTableName( "proc_more_res", __FILE__ ));
|
||||
const QString procName(qTableName("proc_more_res", __FILE__, db));
|
||||
|
||||
q.exec( QString( "DROP PROCEDURE %1;" ).arg( procName ) );
|
||||
|
||||
@ -2748,7 +2748,7 @@ void tst_QSqlQuery::blobsPreparedQuery()
|
||||
if ( !db.driver()->hasFeature( QSqlDriver::BLOB ) || !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) )
|
||||
QSKIP( "DBMS does not support BLOBs or prepared queries");
|
||||
|
||||
const QString tableName(qTableName( "blobstest", __FILE__ ));
|
||||
const QString tableName(qTableName("blobstest", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
q.setForwardOnly( true ); // This is needed to make the test work with DB2.
|
||||
@ -2803,10 +2803,10 @@ void tst_QSqlQuery::emptyTableNavigate()
|
||||
|
||||
{
|
||||
QSqlQuery q( db );
|
||||
const QString tbl = qTableName("qtest_empty", __FILE__);
|
||||
const QString tbl = qTableName("qtest_empty", __FILE__, db);
|
||||
q.exec("drop table " + tbl);
|
||||
QVERIFY_SQL(q, exec("create table " + tbl + " (id char(10))"));
|
||||
QVERIFY_SQL(q, prepare("select * from " + qTableName("qtest_empty", __FILE__ )));
|
||||
QVERIFY_SQL(q, prepare("select * from " + tbl));
|
||||
QVERIFY_SQL( q, exec() );
|
||||
QVERIFY( !q.next() );
|
||||
QCOMPARE( q.lastError().isValid(), false );
|
||||
@ -2819,7 +2819,7 @@ void tst_QSqlQuery::task_217003()
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
QSqlQuery q( db );
|
||||
const QString Planet(qTableName( "Planet", __FILE__));
|
||||
const QString Planet(qTableName( "Planet", __FILE__, db));
|
||||
|
||||
q.exec("drop table " + Planet);
|
||||
QVERIFY_SQL( q, exec( "create table " + Planet + " (Name varchar(20))" ) );
|
||||
@ -2850,7 +2850,7 @@ void tst_QSqlQuery::task_250026()
|
||||
CHECK_DATABASE( db );
|
||||
QSqlQuery q( db );
|
||||
|
||||
const QString tableName(qTableName( "task_250026", __FILE__ ));
|
||||
const QString tableName(qTableName("task_250026", __FILE__, db));
|
||||
|
||||
if ( !q.exec( "create table " + tableName + " (longfield varchar(1100))" ) ) {
|
||||
qDebug() << "Error" << q.lastError();
|
||||
@ -2898,7 +2898,7 @@ void tst_QSqlQuery::task_229811()
|
||||
|
||||
QSqlQuery q( db );
|
||||
|
||||
const QString tableName(qTableName( "task_229811", __FILE__ ));
|
||||
const QString tableName(qTableName("task_229811", __FILE__, db));
|
||||
|
||||
if ( !q.exec( "CREATE TABLE " + tableName + " (Word varchar(20))" ) ) {
|
||||
qDebug() << "Warning" << q.lastError();
|
||||
@ -2945,7 +2945,7 @@ void tst_QSqlQuery::task_234422()
|
||||
m_airlines << "Lufthansa" << "SAS" << "United" << "KLM" << "Aeroflot";
|
||||
m_countries << "DE" << "SE" << "US" << "NL" << "RU";
|
||||
|
||||
const QString tableName(qTableName( "task_234422", __FILE__ ));
|
||||
const QString tableName(qTableName("task_234422", __FILE__, db));
|
||||
|
||||
QVERIFY_SQL(query,exec("CREATE TABLE " + tableName + " (id int primary key, "
|
||||
"name varchar(20), homecountry varchar(2))"));
|
||||
@ -2977,7 +2977,7 @@ void tst_QSqlQuery::task_233829()
|
||||
CHECK_DATABASE( db );
|
||||
|
||||
QSqlQuery q( db );
|
||||
const QString tableName(qTableName("task_233829", __FILE__));
|
||||
const QString tableName(qTableName("task_233829", __FILE__, db));
|
||||
QVERIFY_SQL(q,exec("CREATE TABLE " + tableName + "(dbl1 double precision,dbl2 double precision) without oids;"));
|
||||
|
||||
QString queryString("INSERT INTO " + tableName +"(dbl1, dbl2) VALUES(?,?)");
|
||||
@ -2997,7 +2997,7 @@ void tst_QSqlQuery::sqlServerReturn0()
|
||||
if (!tst_Databases::isSqlServer( db ))
|
||||
QSKIP("SQL Server specific test");
|
||||
|
||||
const QString tableName(qTableName("test141895", __FILE__)), procName(qTableName("test141895_proc", __FILE__));
|
||||
const QString tableName(qTableName("test141895", __FILE__, db)), procName(qTableName("test141895_proc", __FILE__, db));
|
||||
QSqlQuery q( db );
|
||||
q.exec("DROP TABLE " + tableName);
|
||||
q.exec("DROP PROCEDURE " + procName);
|
||||
@ -3023,7 +3023,7 @@ void tst_QSqlQuery::QTBUG_551()
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
QSqlQuery q(db);
|
||||
const QString pkgname(qTableName("pkg", __FILE__));
|
||||
const QString pkgname(qTableName("pkg", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\
|
||||
\n\
|
||||
TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\
|
||||
@ -3070,7 +3070,7 @@ void tst_QSqlQuery::QTBUG_14132()
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
QSqlQuery q(db);
|
||||
const QString procedureName(qTableName("procedure", __FILE__));
|
||||
const QString procedureName(qTableName("procedure", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec("CREATE OR REPLACE PROCEDURE "+ procedureName + " (outStr OUT varchar2) \n\
|
||||
is \n\
|
||||
begin \n\
|
||||
@ -3093,7 +3093,7 @@ void tst_QSqlQuery::QTBUG_18435()
|
||||
return;
|
||||
|
||||
QSqlQuery q(db);
|
||||
QString procName(qTableName("qtbug_18435_proc", __FILE__));
|
||||
QString procName(qTableName("qtbug_18435_proc", __FILE__, db));
|
||||
|
||||
q.exec("DROP PROCEDURE " + procName);
|
||||
const QString stmt =
|
||||
@ -3118,7 +3118,7 @@ void tst_QSqlQuery::QTBUG_5251()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString timetest(qTableName("timetest", __FILE__));
|
||||
const QString timetest(qTableName("timetest", __FILE__, db));
|
||||
|
||||
if (!db.driverName().startsWith( "QPSQL" )) return;
|
||||
|
||||
@ -3151,7 +3151,7 @@ void tst_QSqlQuery::QTBUG_6421()
|
||||
CHECK_DATABASE( db );
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("bug6421", __FILE__).toUpper());
|
||||
const QString tableName(qTableName("bug6421", __FILE__, db).toUpper());
|
||||
|
||||
QVERIFY_SQL(q, exec("create table "+tableName+"(COL1 char(10), COL2 char(10), COL3 char(10))"));
|
||||
QVERIFY_SQL(q, exec("create index INDEX1 on "+tableName+" (COL1 desc)"));
|
||||
@ -3176,16 +3176,16 @@ void tst_QSqlQuery::QTBUG_6618()
|
||||
QSKIP("SQL Server specific test");
|
||||
|
||||
QSqlQuery q(db);
|
||||
q.exec( "drop procedure " + qTableName( "tst_raiseError", __FILE__ ) ); //non-fatal
|
||||
q.exec("drop procedure " + qTableName("tst_raiseError", __FILE__, db)); //non-fatal
|
||||
QString errorString;
|
||||
for (int i=0;i<110;i++)
|
||||
errorString+="reallylong";
|
||||
errorString+=" error";
|
||||
QVERIFY_SQL( q, exec("create procedure " + qTableName( "tst_raiseError", __FILE__ ) + " as\n"
|
||||
QVERIFY_SQL(q, exec("create procedure " + qTableName("tst_raiseError", __FILE__, db) + " as\n"
|
||||
"begin\n"
|
||||
" raiserror('" + errorString + "', 16, 1)\n"
|
||||
"end\n" ));
|
||||
q.exec( "{call " + qTableName( "tst_raiseError", __FILE__ ) + "}" );
|
||||
q.exec("{call " + qTableName("tst_raiseError", __FILE__, db) + "}");
|
||||
QVERIFY(q.lastError().text().contains(errorString));
|
||||
}
|
||||
|
||||
@ -3198,7 +3198,7 @@ void tst_QSqlQuery::QTBUG_6852()
|
||||
QSKIP( "Test requires MySQL >= 5.0");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("bug6852", __FILE__)), procName(qTableName("bug6852_proc", __FILE__));
|
||||
const QString tableName(qTableName("bug6852", __FILE__, db)), procName(qTableName("bug6852_proc", __FILE__, db));
|
||||
|
||||
QVERIFY_SQL(q, exec("DROP PROCEDURE IF EXISTS "+procName));
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n"
|
||||
@ -3232,7 +3232,7 @@ void tst_QSqlQuery::QTBUG_5765()
|
||||
QSKIP( "Test requires MySQL >= 4.1");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("bug5765", __FILE__));
|
||||
const QString tableName(qTableName("bug5765", __FILE__, db));
|
||||
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(testval TINYINT(1) DEFAULT 0)"));
|
||||
q.prepare("INSERT INTO "+tableName+" SET testval = :VALUE");
|
||||
@ -3275,7 +3275,7 @@ void tst_QSqlQuery::QTBUG_21884()
|
||||
QSqlQuery q(db);
|
||||
|
||||
QStringList stList;
|
||||
QString tableName(qTableName("bug21884", __FILE__ ));
|
||||
QString tableName(qTableName("bug21884", __FILE__, db));
|
||||
stList << "create table " + tableName + "(id integer primary key, note string)";
|
||||
stList << "select * from " + tableName + ";";
|
||||
stList << "select * from " + tableName + "; \t\n\r";
|
||||
@ -3370,7 +3370,7 @@ void tst_QSqlQuery::QTBUG_23895()
|
||||
|
||||
QSqlQuery q(db);
|
||||
|
||||
QString tableName(qTableName("bug23895", __FILE__ ));
|
||||
QString tableName(qTableName("bug23895", __FILE__, db));
|
||||
q.prepare("create table " + tableName + "(id integer primary key, val1 bool, val2 boolean)");
|
||||
QVERIFY_SQL(q, exec());
|
||||
q.prepare("insert into " + tableName + "(id, val1, val2) values(?, ?, ?);");
|
||||
@ -3425,7 +3425,7 @@ void tst_QSqlQuery::QTBUG_14904()
|
||||
|
||||
QSqlQuery q(db);
|
||||
|
||||
QString tableName(qTableName("bug14904", __FILE__ ));
|
||||
QString tableName(qTableName("bug14904", __FILE__, db));
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
q.prepare("create table " + tableName + "(val1 bool)");
|
||||
@ -3456,7 +3456,7 @@ void tst_QSqlQuery::QTBUG_2192()
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
{
|
||||
const QString tableName(qTableName("bug2192", __FILE__));
|
||||
const QString tableName(qTableName("bug2192", __FILE__, db));
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
QSqlQuery q(db);
|
||||
@ -3483,7 +3483,7 @@ void tst_QSqlQuery::oraOCINumber()
|
||||
QFETCH( QString, dbName );
|
||||
QSqlDatabase db = QSqlDatabase::database( dbName );
|
||||
CHECK_DATABASE( db );
|
||||
const QString qtest_oraOCINumber(qTableName("qtest_oraOCINumber", __FILE__));
|
||||
const QString qtest_oraOCINumber(qTableName("qtest_oraOCINumber", __FILE__, db));
|
||||
|
||||
QSqlQuery q( db );
|
||||
q.setForwardOnly( true );
|
||||
@ -3592,7 +3592,7 @@ void tst_QSqlQuery::sqlite_constraint()
|
||||
QSKIP("Sqlite3 specific test");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString trigger(qTableName("test_constraint", __FILE__));
|
||||
const QString trigger(qTableName("test_constraint", __FILE__, db));
|
||||
|
||||
QVERIFY_SQL(q, exec("CREATE TEMP TRIGGER "+trigger+" BEFORE DELETE ON "+qtest+
|
||||
"\nFOR EACH ROW "
|
||||
@ -3610,7 +3610,7 @@ void tst_QSqlQuery::sqlite_real()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString tableName(qTableName("sqliterealtype", __FILE__));
|
||||
const QString tableName(qTableName("sqliterealtype", __FILE__, db));
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
QSqlQuery q(db);
|
||||
@ -3641,8 +3641,10 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
||||
// QPSQL uses LongLong for manipulation of integers
|
||||
if (db.driverName().startsWith("QPSQL") || db.driverName().startsWith("QMYSQL"))
|
||||
intType = QVariant::LongLong;
|
||||
else if (db.driverName().startsWith("QOCI"))
|
||||
intType = QVariant::Double;
|
||||
{
|
||||
const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__));
|
||||
const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__, db));
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
QSqlQuery q(db);
|
||||
@ -3672,7 +3674,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
||||
QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName));
|
||||
QVERIFY(q.next());
|
||||
if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QPSQL")
|
||||
|| (db.driverName().startsWith("QMYSQL"))) {
|
||||
|| db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QOCI")) {
|
||||
QCOMPARE(q.value(0).toDouble(), 1.5);
|
||||
QCOMPARE(q.record().field(0).type(), QVariant::Double);
|
||||
} else {
|
||||
@ -3688,15 +3690,15 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
||||
QVERIFY_SQL(q, exec("SELECT MIN(id) FROM " + tableName));
|
||||
QVERIFY(q.next());
|
||||
QCOMPARE(q.value(0).toInt(), 1);
|
||||
QCOMPARE(q.record().field(0).type(), QVariant::Int);
|
||||
QCOMPARE(q.record().field(0).type(), intType);
|
||||
|
||||
QVERIFY_SQL(q, exec("SELECT MAX(id) FROM " + tableName));
|
||||
QVERIFY(q.next());
|
||||
QCOMPARE(q.value(0).toInt(), 2);
|
||||
QCOMPARE(q.record().field(0).type(), QVariant::Int);
|
||||
QCOMPARE(q.record().field(0).type(), intType);
|
||||
}
|
||||
{
|
||||
const QString tableName(qTableName("numericFunctionsWithDoubleValues", __FILE__));
|
||||
const QString tableName(qTableName("numericFunctionsWithDoubleValues", __FILE__, db));
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
QSqlQuery q(db);
|
||||
@ -3755,7 +3757,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
||||
}
|
||||
}
|
||||
{
|
||||
const QString tableName(qTableName("stringFunctions", __FILE__));
|
||||
const QString tableName(qTableName("stringFunctions", __FILE__, db));
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
QSqlQuery q(db);
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
const QString qtest(qTableName("qtest", __FILE__));
|
||||
const QString qtest(qTableName("qtest", __FILE__, QSqlDatabase()));
|
||||
// set this define if Oracle is built with threading support
|
||||
//#define QOCI_THREADED
|
||||
|
||||
@ -303,7 +303,7 @@ void tst_QSqlThread::dropTestTables()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
|
||||
QSqlQuery q(db);
|
||||
|
||||
tst_Databases::safeDropTables(db, QStringList() << qtest << qTableName("qtest2", __FILE__) << qTableName("emptytable", __FILE__));
|
||||
tst_Databases::safeDropTables(db, QStringList() << qtest << qTableName("qtest2", __FILE__, db) << qTableName("emptytable", __FILE__, db));
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,10 +316,10 @@ void tst_QSqlThread::createTestTables()
|
||||
QVERIFY_SQL(q, exec("create table " + qtest
|
||||
+ "(id int NOT NULL primary key, name varchar(20), title int)"));
|
||||
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest2", __FILE__)
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest2", __FILE__, db)
|
||||
+ "(id int NOT NULL primary key, title varchar(20))"));
|
||||
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("emptytable", __FILE__)
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("emptytable", __FILE__, db)
|
||||
+ "(id int NOT NULL primary key)"));
|
||||
}
|
||||
}
|
||||
@ -335,9 +335,9 @@ void tst_QSqlThread::repopulateTestTables()
|
||||
QVERIFY_SQL(q, exec("insert into " + qtest + " values(2, 'trond', 2)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qtest + " values(3, 'vohi', 3)"));
|
||||
|
||||
QVERIFY_SQL(q, exec("delete from " + qTableName("qtest2", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__) + " values(1, 'herr')"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__) + " values(2, 'mister')"));
|
||||
QVERIFY_SQL(q, exec("delete from " + qTableName("qtest2", __FILE__, db)));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__, db) + " values(1, 'herr')"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__, db) + " values(2, 'mister')"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,10 +147,10 @@ void tst_QSqlQueryModel::cleanupTestCase()
|
||||
void tst_QSqlQueryModel::dropTestTables(QSqlDatabase db)
|
||||
{
|
||||
QStringList tableNames;
|
||||
tableNames << qTableName("test", __FILE__)
|
||||
<< qTableName("test2", __FILE__)
|
||||
<< qTableName("test3", __FILE__)
|
||||
<< qTableName("many", __FILE__);
|
||||
tableNames << qTableName("test", __FILE__, db)
|
||||
<< qTableName("test2", __FILE__, db)
|
||||
<< qTableName("test3", __FILE__, db)
|
||||
<< qTableName("many", __FILE__, db);
|
||||
tst_Databases::safeDropTables(db, tableNames);
|
||||
}
|
||||
|
||||
@ -160,10 +160,10 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db)
|
||||
QSqlQuery q(db);
|
||||
if(tst_Databases::isPostgreSQL(db))
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__) + "(id integer not null, name varchar(20), title integer, primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__) + "(id integer not null, title varchar(20), primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__) + "(id integer not null, primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("many", __FILE__) + "(id integer not null, name varchar(20), primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__, db) + "(id integer not null, name varchar(20), title integer, primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__, db) + "(id integer not null, title varchar(20), primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__, db) + "(id integer not null, primary key (id))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("many", __FILE__, db) + "(id integer not null, name varchar(20), primary key (id))"));
|
||||
}
|
||||
|
||||
void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db)
|
||||
@ -173,38 +173,38 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db)
|
||||
|
||||
QSqlQuery q(db), q2(db);
|
||||
|
||||
tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("manytmp", __FILE__) + "(id integer not null, name varchar(20), primary key (id))"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp", __FILE__) + "(id integer not null, primary key (id))"));
|
||||
tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__, db) << qTableName("test3tmp", __FILE__, db));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("manytmp", __FILE__, db) + "(id integer not null, name varchar(20), primary key (id))"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp", __FILE__, db) + "(id integer not null, primary key (id))"));
|
||||
|
||||
if (hasTransactions) QVERIFY_SQL(db, transaction());
|
||||
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(1, 'harry', 1)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(2, 'trond', 2)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(1, 'herr')"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(2, 'mister')"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__, db) + " values(1, 'harry', 1)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__, db) + " values(2, 'trond', 2)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__, db) + " values(1, 'herr')"));
|
||||
QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__, db) + " values(2, 'mister')"));
|
||||
|
||||
QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3", __FILE__) + " values(0)")));
|
||||
QVERIFY_SQL(q, prepare("insert into "+qTableName("test3", __FILE__)+"(id) select id + ? from "+qTableName("test3tmp", __FILE__)));
|
||||
QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3", __FILE__, db) + " values(0)")));
|
||||
QVERIFY_SQL(q, prepare("insert into "+ qTableName("test3", __FILE__, db) + "(id) select id + ? from " + qTableName("test3tmp", __FILE__, db)));
|
||||
for (int i=1; i<260; i*=2) {
|
||||
q2.exec("delete from "+qTableName("test3tmp", __FILE__));
|
||||
QVERIFY_SQL(q2, exec("insert into "+qTableName("test3tmp", __FILE__)+"(id) select id from "+qTableName("test3", __FILE__)));
|
||||
q2.exec("delete from " + qTableName("test3tmp", __FILE__, db));
|
||||
QVERIFY_SQL(q2, exec("insert into " + qTableName("test3tmp", __FILE__, db) + "(id) select id from " + qTableName("test3", __FILE__, db)));
|
||||
q.bindValue(0, i);
|
||||
QVERIFY_SQL(q, exec());
|
||||
}
|
||||
|
||||
QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many", __FILE__) + "(id, name) values (0, \'harry\')")));
|
||||
QVERIFY_SQL(q, prepare("insert into "+qTableName("many", __FILE__)+"(id, name) select id + ?, name from "+qTableName("manytmp", __FILE__)));
|
||||
QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many", __FILE__, db) + "(id, name) values (0, \'harry\')")));
|
||||
QVERIFY_SQL(q, prepare("insert into " + qTableName("many", __FILE__, db) + "(id, name) select id + ?, name from " + qTableName("manytmp", __FILE__, db)));
|
||||
for (int i=1; i < 2048; i*=2) {
|
||||
q2.exec("delete from "+qTableName("manytmp", __FILE__));
|
||||
QVERIFY_SQL(q2, exec("insert into "+qTableName("manytmp", __FILE__)+"(id, name) select id, name from "+qTableName("many", __FILE__)));
|
||||
q2.exec("delete from " + qTableName("manytmp", __FILE__, db));
|
||||
QVERIFY_SQL(q2, exec("insert into " + qTableName("manytmp", __FILE__, db) + "(id, name) select id, name from " + qTableName("many", __FILE__, db)));
|
||||
q.bindValue(0, i);
|
||||
QVERIFY_SQL(q, exec());
|
||||
}
|
||||
|
||||
if (hasTransactions) QVERIFY_SQL(db, commit());
|
||||
|
||||
tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__));
|
||||
tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__, db) << qTableName("test3tmp", __FILE__, db));
|
||||
}
|
||||
|
||||
void tst_QSqlQueryModel::generic_data(const QString& engine)
|
||||
@ -232,7 +232,7 @@ void tst_QSqlQueryModel::removeColumn()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
DBTestModel model;
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
|
||||
model.fetchMore();
|
||||
QSignalSpy spy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)));
|
||||
|
||||
@ -314,7 +314,7 @@ void tst_QSqlQueryModel::insertColumn()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
DBTestModel model;
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
|
||||
model.fetchMore(); // necessary???
|
||||
|
||||
bool isToUpper = db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2");
|
||||
@ -417,7 +417,7 @@ void tst_QSqlQueryModel::record()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQueryModel model;
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
|
||||
|
||||
QSqlRecord rec = model.record();
|
||||
|
||||
@ -451,7 +451,7 @@ void tst_QSqlQueryModel::setHeaderData()
|
||||
QVERIFY(!model.setHeaderData(5, Qt::Vertical, "foo"));
|
||||
QVERIFY(model.headerData(5, Qt::Vertical).isValid());
|
||||
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__, db), db));
|
||||
|
||||
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
|
||||
QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
|
||||
@ -482,7 +482,7 @@ void tst_QSqlQueryModel::fetchMore()
|
||||
QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
|
||||
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
|
||||
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__, db), db));
|
||||
int rowCount = model.rowCount();
|
||||
|
||||
QCOMPARE(modelAboutToBeResetSpy.count(), 1);
|
||||
@ -514,7 +514,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel()
|
||||
QSKIP("Test applies only for drivers not reporting the query size.");
|
||||
|
||||
QSqlQueryModel model;
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__, db), db));
|
||||
QSortFilterProxyModel proxy;
|
||||
proxy.setSourceModel(&model);
|
||||
|
||||
@ -524,7 +524,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel()
|
||||
QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset()));
|
||||
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
|
||||
QSignalSpy modelRowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex,int,int)));
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__, db), db));
|
||||
view.scrollToBottom();
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
@ -555,13 +555,13 @@ void tst_QSqlQueryModel::setQuerySignalEmission()
|
||||
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
|
||||
|
||||
// First select, the model was empty and no rows had to be removed, but model resets anyway.
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db));
|
||||
QCOMPARE(modelAboutToBeResetSpy.count(), 1);
|
||||
QCOMPARE(modelResetSpy.count(), 1);
|
||||
|
||||
// Second select, the model wasn't empty and two rows had to be removed!
|
||||
// setQuery() resets the model accompanied by begin and end signals
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db));
|
||||
model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__, db), db));
|
||||
QCOMPARE(modelAboutToBeResetSpy.count(), 2);
|
||||
QCOMPARE(modelResetSpy.count(), 2);
|
||||
}
|
||||
@ -580,7 +580,7 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet()
|
||||
|
||||
// The query's result set will be empty so no signals should be emitted!
|
||||
QSqlQuery query(db);
|
||||
QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__) + " where 0 = 1"));
|
||||
QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__, db) + " where 0 = 1"));
|
||||
model.setQuery(query);
|
||||
QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0);
|
||||
QCOMPARE(modelRowsInsertedSpy.count(), 0);
|
||||
@ -649,7 +649,7 @@ void tst_QSqlQueryModel::task_180617()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString test3(qTableName("test3", __FILE__));
|
||||
const QString test3(qTableName("test3", __FILE__, db));
|
||||
|
||||
QTableView view;
|
||||
QCOMPARE(view.columnAt(0), -1);
|
||||
|
@ -45,11 +45,11 @@
|
||||
|
||||
#include "../../kernel/qsqldatabase/tst_databases.h"
|
||||
|
||||
const QString reltest1(qTableName("reltest1", __FILE__)),
|
||||
reltest2(qTableName("reltest2", __FILE__)),
|
||||
reltest3(qTableName("reltest3", __FILE__)),
|
||||
reltest4(qTableName("reltest4", __FILE__)),
|
||||
reltest5(qTableName("reltest5", __FILE__));
|
||||
const QString reltest1(qTableName("reltest1", __FILE__, QSqlDatabase())),
|
||||
reltest2(qTableName("reltest2", __FILE__, QSqlDatabase())),
|
||||
reltest3(qTableName("reltest3", __FILE__, QSqlDatabase())),
|
||||
reltest4(qTableName("reltest4", __FILE__, QSqlDatabase())),
|
||||
reltest5(qTableName("reltest5", __FILE__, QSqlDatabase()));
|
||||
|
||||
class tst_QSqlRelationalTableModel : public QObject
|
||||
{
|
||||
@ -134,13 +134,13 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db)
|
||||
QVERIFY_SQL( q, exec("insert into " + reltest5 + " values('mister', 'Mr')"));
|
||||
|
||||
if (testWhiteSpaceNames(db.driverName())) {
|
||||
QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test6", QSqlDriver::TableName);
|
||||
QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__, db) + " test6", QSqlDriver::TableName);
|
||||
QVERIFY_SQL( q, exec("create table " + reltest6 + " (id int not null primary key, " + db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName) +
|
||||
" int, " + db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName) + " int)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(1, 1,9)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(2, 2,8)"));
|
||||
|
||||
QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test7", QSqlDriver::TableName);
|
||||
QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__, db) + " test7", QSqlDriver::TableName);
|
||||
QVERIFY_SQL( q, exec("create table " + reltest7 + " (" + db.driver()->escapeIdentifier("city id", QSqlDriver::TableName) + " int not null primary key, " + db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName) + " varchar(20))"));
|
||||
QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(1, 'New York')"));
|
||||
QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(2, 'Washington')"));
|
||||
@ -181,14 +181,14 @@ void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db )
|
||||
<< reltest3
|
||||
<< reltest4
|
||||
<< reltest5
|
||||
<< (qTableName( "rel", __FILE__)+" test6")
|
||||
<< (qTableName( "rel", __FILE__)+" test7")
|
||||
<< qTableName("CASETEST1", db.driver() )
|
||||
<< qTableName("casetest1", db.driver() );
|
||||
<< (qTableName("rel", __FILE__, db) + " test6")
|
||||
<< (qTableName( "rel", __FILE__, db) + " test7")
|
||||
<< qTableName("CASETEST1", db)
|
||||
<< qTableName("casetest1", db);
|
||||
tst_Databases::safeDropTables( db, tableNames );
|
||||
|
||||
db.exec("DROP SCHEMA "+qTableName("QTBUG_5373", __FILE__)+" CASCADE");
|
||||
db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2", __FILE__)+" CASCADE");
|
||||
db.exec("DROP SCHEMA " + qTableName("QTBUG_5373", __FILE__, db) + " CASCADE");
|
||||
db.exec("DROP SCHEMA " + qTableName("QTBUG_5373_s2", __FILE__, db) + " CASCADE");
|
||||
}
|
||||
|
||||
void tst_QSqlRelationalTableModel::init()
|
||||
@ -1095,54 +1095,54 @@ void tst_QSqlRelationalTableModel::casing()
|
||||
QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities");
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() +
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db).toUpper() +
|
||||
" (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
|
||||
|
||||
if( !q.exec("create table " + qTableName("casetest1", db.driver()) +
|
||||
if (!q.exec("create table " + qTableName("casetest1", db) +
|
||||
" (ident int not null primary key, name varchar(20), title_key int)"))
|
||||
QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities");
|
||||
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(1, 'harry', 1, 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(2, 'trond', 2, 1)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(3, 'vohi', 1, 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(4, 'boris', 2, 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(1, 'jerry', 1)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(2, 'george', 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(4, 'kramer', 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db).toUpper() + " values(1, 'harry', 1, 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db).toUpper() + " values(2, 'trond', 2, 1)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db).toUpper() + " values(3, 'vohi', 1, 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db).toUpper() + " values(4, 'boris', 2, 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(1, 'jerry', 1)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(2, 'george', 2)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db) + " values(4, 'kramer', 2)"));
|
||||
|
||||
if (db.driverName().startsWith("QOCI")) {
|
||||
//try an owner that doesn't exist
|
||||
QSqlRecord rec = db.driver()->record("doug." + qTableName("CASETEST1", db.driver()).toUpper());
|
||||
QSqlRecord rec = db.driver()->record("doug." + qTableName("CASETEST1", db).toUpper());
|
||||
QCOMPARE( rec.count(), 0);
|
||||
|
||||
//try an owner that does exist
|
||||
rec = db.driver()->record(db.userName() + "." + qTableName("CASETEST1", db.driver()).toUpper());
|
||||
rec = db.driver()->record(db.userName() + "." + qTableName("CASETEST1", db).toUpper());
|
||||
QCOMPARE( rec.count(), 4);
|
||||
}
|
||||
QSqlRecord rec = db.driver()->record(qTableName("CASETEST1", db.driver()).toUpper());
|
||||
QSqlRecord rec = db.driver()->record(qTableName("CASETEST1", db).toUpper());
|
||||
QCOMPARE( rec.count(), 4);
|
||||
|
||||
rec = db.driver()->record(qTableName("casetest1", db.driver()));
|
||||
rec = db.driver()->record(qTableName("casetest1", db));
|
||||
QCOMPARE( rec.count(), 3);
|
||||
|
||||
QSqlTableModel upperCaseModel(0, db);
|
||||
upperCaseModel.setTable(qTableName("CASETEST1", db.driver()).toUpper());
|
||||
upperCaseModel.setTable(qTableName("CASETEST1", db).toUpper());
|
||||
|
||||
QCOMPARE(upperCaseModel.tableName(),qTableName("CASETEST1",db.driver()).toUpper());
|
||||
QCOMPARE(upperCaseModel.tableName(), qTableName("CASETEST1", db).toUpper());
|
||||
|
||||
QVERIFY_SQL(upperCaseModel, select());
|
||||
|
||||
QCOMPARE(upperCaseModel.rowCount(), 4);
|
||||
|
||||
QSqlTableModel lowerCaseModel(0, db);
|
||||
lowerCaseModel.setTable(qTableName("casetest1", db.driver()));
|
||||
QCOMPARE(lowerCaseModel.tableName(), qTableName("casetest1",db.driver()));
|
||||
lowerCaseModel.setTable(qTableName("casetest1", db));
|
||||
QCOMPARE(lowerCaseModel.tableName(), qTableName("casetest1", db));
|
||||
QVERIFY_SQL(lowerCaseModel, select());
|
||||
|
||||
QCOMPARE(lowerCaseModel.rowCount(), 3);
|
||||
|
||||
QSqlRelationalTableModel model(0, db);
|
||||
model.setTable(qTableName("CASETEST1", db.driver()).toUpper());
|
||||
model.setTable(qTableName("CASETEST1", db).toUpper());
|
||||
model.setRelation(2, QSqlRelation(reltest2, "tid", "title"));
|
||||
QVERIFY_SQL(model, select());
|
||||
|
||||
@ -1372,9 +1372,9 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers()
|
||||
if (!testWhiteSpaceNames(db.driverName()))
|
||||
QSKIP("White space test irrelevant for driver");
|
||||
QSqlRelationalTableModel model(0, db);
|
||||
model.setTable(db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test6", QSqlDriver::TableName));
|
||||
model.setTable(db.driver()->escapeIdentifier(qTableName("rel", __FILE__, db) + " test6", QSqlDriver::TableName));
|
||||
model.setSort(0, Qt::DescendingOrder);
|
||||
model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test7", QSqlDriver::TableName),
|
||||
model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel", __FILE__, db) + " test7", QSqlDriver::TableName),
|
||||
db.driver()->escapeIdentifier("city id", QSqlDriver::FieldName),
|
||||
db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName)));
|
||||
QVERIFY_SQL(model, select());
|
||||
@ -1459,13 +1459,15 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest()
|
||||
|
||||
QSqlRelationalTableModel model(0, db);
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2", __FILE__)));
|
||||
QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373", __FILE__)+"."+qTableName("document", __FILE__)+"(document_id int primary key, relatingid int, userid int)"));
|
||||
QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__)+"(userid int primary key, username char(40))"));
|
||||
model.setTable(qTableName("QTBUG_5373", __FILE__)+"."+qTableName("document", __FILE__));
|
||||
model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__), "userid", "username"));
|
||||
model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__), "userid", "username"));
|
||||
QVERIFY_SQL(q, exec("create schema " + qTableName("QTBUG_5373", __FILE__, db)));
|
||||
QVERIFY_SQL(q, exec("create schema " + qTableName("QTBUG_5373_s2", __FILE__, db)));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373", __FILE__, db) + "." + qTableName("document", __FILE__, db) +
|
||||
"(document_id int primary key, relatingid int, userid int)"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db) +
|
||||
"(userid int primary key, username char(40))"));
|
||||
model.setTable(qTableName("QTBUG_5373", __FILE__, db) + "." + qTableName("document", __FILE__, db));
|
||||
model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db), "userid", "username"));
|
||||
model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db), "userid", "username"));
|
||||
QVERIFY_SQL(model, select());
|
||||
|
||||
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
|
||||
@ -1503,8 +1505,8 @@ void tst_QSqlRelationalTableModel::relationOnFirstColumn()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString testTable1 = qTableName("QTBUG_20038_test1", __FILE__);
|
||||
QString testTable2 = qTableName("QTBUG_20038_test2", __FILE__);
|
||||
QString testTable1 = qTableName("QTBUG_20038_test1", __FILE__, db);
|
||||
QString testTable2 = qTableName("QTBUG_20038_test2", __FILE__, db);
|
||||
tst_Databases::safeDropTables(db, QStringList() << testTable1 << testTable2);
|
||||
|
||||
//prepare test1 table
|
||||
|
@ -45,9 +45,9 @@
|
||||
#include <QtSql>
|
||||
#include <QtSql/private/qsqltablemodel_p.h>
|
||||
|
||||
const QString test(qTableName("test", __FILE__)),
|
||||
test2(qTableName("test2", __FILE__)),
|
||||
test3(qTableName("test3", __FILE__));
|
||||
const QString test(qTableName("test", __FILE__, QSqlDatabase())),
|
||||
test2(qTableName("test2", __FILE__, QSqlDatabase())),
|
||||
test3(qTableName("test3", __FILE__, QSqlDatabase()));
|
||||
|
||||
|
||||
class tst_QSqlTableModel : public QObject
|
||||
@ -176,18 +176,18 @@ void tst_QSqlTableModel::dropTestTables()
|
||||
tableNames << test
|
||||
<< test2
|
||||
<< test3
|
||||
<< qTableName("test4", __FILE__)
|
||||
<< qTableName("emptytable", __FILE__)
|
||||
<< qTableName("bigtable", __FILE__)
|
||||
<< qTableName("foo", __FILE__)
|
||||
<< qTableName("pktest", __FILE__);
|
||||
<< qTableName("test4", __FILE__, db)
|
||||
<< qTableName("emptytable", __FILE__, db)
|
||||
<< qTableName("bigtable", __FILE__, db)
|
||||
<< qTableName("foo", __FILE__, db)
|
||||
<< qTableName("pktest", __FILE__, db);
|
||||
if (testWhiteSpaceNames(db.driverName()))
|
||||
tableNames << qTableName("qtestw hitespace", db.driver());
|
||||
tableNames << qTableName("qtestw hitespace", db);
|
||||
|
||||
tst_Databases::safeDropTables(db, tableNames);
|
||||
|
||||
if (db.driverName().startsWith("QPSQL")) {
|
||||
q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__) + " CASCADE");
|
||||
q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__, db) + " CASCADE");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,19 +205,19 @@ void tst_QSqlTableModel::createTestTables()
|
||||
QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))"));
|
||||
|
||||
if(!tst_Databases::isSqlServer(db))
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))"));
|
||||
else
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50) NULL, column3 varchar(50))"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50) NULL, column3 varchar(50))"));
|
||||
|
||||
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("emptytable", __FILE__) + "(id int)"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("emptytable", __FILE__, db) + "(id int)"));
|
||||
|
||||
if (testWhiteSpaceNames(db.driverName())) {
|
||||
QString qry = "create table " + qTableName("qtestw hitespace", db.driver()) + " ("+ db.driver()->escapeIdentifier("a field", QSqlDriver::FieldName) + " int)";
|
||||
QString qry = "create table " + qTableName("qtestw hitespace", db) + " ("+ db.driver()->escapeIdentifier("a field", QSqlDriver::FieldName) + " int)";
|
||||
QVERIFY_SQL( q, exec(qry));
|
||||
}
|
||||
|
||||
QVERIFY_SQL( q, exec("create table "+qTableName("pktest", __FILE__)+"(id int not null primary key, a varchar(20))"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("pktest", __FILE__, db) + "(id int not null primary key, a varchar(20))"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ void tst_QSqlTableModel::selectRow()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tbl = qTableName("pktest", __FILE__);
|
||||
QString tbl = qTableName("pktest", __FILE__, db);
|
||||
QSqlQuery q(db);
|
||||
q.exec("DELETE FROM " + tbl);
|
||||
q.exec("INSERT INTO " + tbl + " (id, a) VALUES (0, 'a')");
|
||||
@ -403,7 +403,7 @@ void tst_QSqlTableModel::selectRowOverride()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tbl = qTableName("pktest", __FILE__);
|
||||
QString tbl = qTableName("pktest", __FILE__, db);
|
||||
QSqlQuery q(db);
|
||||
q.exec("DELETE FROM " + tbl);
|
||||
q.exec("INSERT INTO " + tbl + " (id, a) VALUES (0, 'a')");
|
||||
@ -827,7 +827,7 @@ void tst_QSqlTableModel::insertRowFailure()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(qTableName("pktest", __FILE__));
|
||||
model.setTable(qTableName("pktest", __FILE__, db));
|
||||
model.setEditStrategy(submitpolicy);
|
||||
|
||||
QSqlRecord values = model.record();
|
||||
@ -975,7 +975,7 @@ void tst_QSqlTableModel::insertWithAutoColumn()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tbl = qTableName("autoColumnTest", __FILE__);
|
||||
QString tbl = qTableName("autoColumnTest", __FILE__, db);
|
||||
QSqlQuery q(db);
|
||||
q.exec("DROP TABLE " + tbl);
|
||||
QVERIFY_SQL(q, exec("CREATE TABLE " + tbl + "(id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT)"));
|
||||
@ -1378,8 +1378,8 @@ void tst_QSqlTableModel::revert()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QString tblA = qTableName("revertATest", __FILE__);
|
||||
QString tblB = qTableName("revertBTest", __FILE__);
|
||||
QString tblA = qTableName("revertATest", __FILE__, db);
|
||||
QString tblB = qTableName("revertBTest", __FILE__, db);
|
||||
QSqlQuery q(db);
|
||||
q.exec("PRAGMA foreign_keys = ON;");
|
||||
q.exec("DROP TABLE " + tblB);
|
||||
@ -1646,7 +1646,7 @@ void tst_QSqlTableModel::emptyTable()
|
||||
QCOMPARE(model.rowCount(), 0);
|
||||
QCOMPARE(model.columnCount(), 0);
|
||||
|
||||
model.setTable(qTableName("emptytable", __FILE__));
|
||||
model.setTable(qTableName("emptytable", __FILE__, db));
|
||||
QCOMPARE(model.rowCount(), 0);
|
||||
QCOMPARE(model.columnCount(), 1);
|
||||
|
||||
@ -1670,9 +1670,9 @@ void tst_QSqlTableModel::tablesAndSchemas()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__) + " CASCADE");
|
||||
QVERIFY_SQL( q, exec("create schema " + qTableName("testschema", __FILE__)));
|
||||
QString tableName = qTableName("testschema", __FILE__) + '.' + qTableName("testtable", __FILE__);
|
||||
q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__, db) + " CASCADE");
|
||||
QVERIFY_SQL( q, exec("create schema " + qTableName("testschema", __FILE__, db)));
|
||||
QString tableName = qTableName("testschema", __FILE__, db) + '.' + qTableName("testtable", __FILE__, db);
|
||||
QVERIFY_SQL( q, exec("create table " + tableName + "(id int)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + tableName + " values(1)"));
|
||||
QVERIFY_SQL( q, exec("insert into " + tableName + " values(2)"));
|
||||
@ -1693,7 +1693,7 @@ void tst_QSqlTableModel::whitespaceInIdentifiers()
|
||||
if (!testWhiteSpaceNames(db.driverName()))
|
||||
QSKIP("DBMS doesn't support whitespaces in identifiers");
|
||||
|
||||
QString tableName = qTableName("qtestw hitespace", db.driver());
|
||||
QString tableName = qTableName("qtestw hitespace", db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(tableName);
|
||||
@ -1711,10 +1711,10 @@ void tst_QSqlTableModel::primaryKeyOrder()
|
||||
if(tst_Databases::isPostgreSQL(db))
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
|
||||
QVERIFY_SQL( q, exec("create table "+qTableName("foo", __FILE__)+"(a varchar(20), id int not null primary key, b varchar(20))"));
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("foo", __FILE__, db) + "(a varchar(20), id int not null primary key, b varchar(20))"));
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(qTableName("foo", __FILE__));
|
||||
model.setTable(qTableName("foo", __FILE__, db));
|
||||
|
||||
QSqlIndex pk = model.primaryKey();
|
||||
QCOMPARE(pk.count(), 1);
|
||||
@ -1783,7 +1783,7 @@ void tst_QSqlTableModel::sqlite_bigTable()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const QString bigtable(qTableName("bigtable", __FILE__));
|
||||
const QString bigtable(qTableName("bigtable", __FILE__, db));
|
||||
|
||||
bool hasTransactions = db.driver()->hasFeature(QSqlDriver::Transactions);
|
||||
if (hasTransactions) QVERIFY(db.transaction());
|
||||
@ -1865,7 +1865,7 @@ void tst_QSqlTableModel::submitAllOnInvalidTable()
|
||||
|
||||
// setTable returns a void, so the error can only be caught by
|
||||
// manually checking lastError(). ### Qt5: This should be changed!
|
||||
model.setTable(qTableName("invalidTable", __FILE__));
|
||||
model.setTable(qTableName("invalidTable", __FILE__, db));
|
||||
QCOMPARE(model.lastError().type(), QSqlError::StatementError);
|
||||
|
||||
// This will give us an empty record which is expected behavior
|
||||
@ -1975,7 +1975,7 @@ void tst_QSqlTableModel::tableModifyWithBlank()
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(qTableName("test4", __FILE__));
|
||||
model.setTable(qTableName("test4", __FILE__, db));
|
||||
model.select();
|
||||
|
||||
//generate a time stamp for the test. Add one second to the current time to make sure
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
#include "../../../../auto/sql/kernel/qsqldatabase/tst_databases.h"
|
||||
|
||||
const QString qtest(qTableName( "qtest", __FILE__ ));
|
||||
const QString qtest(qTableName("qtest", __FILE__, QSqlDatabase()));
|
||||
|
||||
class tst_QSqlQuery : public QObject
|
||||
{
|
||||
@ -149,56 +149,56 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
|
||||
QStringList tablenames;
|
||||
// drop all the table in case a testcase failed
|
||||
tablenames << qtest
|
||||
<< qTableName( "qtest_null", __FILE__ )
|
||||
<< qTableName( "qtest_blob", __FILE__ )
|
||||
<< qTableName( "qtest_bittest", __FILE__ )
|
||||
<< qTableName( "qtest_nullblob", __FILE__ )
|
||||
<< qTableName( "qtest_rawtest", __FILE__ )
|
||||
<< qTableName( "qtest_precision", __FILE__ )
|
||||
<< qTableName( "qtest_prepare", __FILE__ )
|
||||
<< qTableName( "qtestj1", __FILE__ )
|
||||
<< qTableName( "qtestj2", __FILE__ )
|
||||
<< qTableName( "char1Select", __FILE__ )
|
||||
<< qTableName( "char1SU", __FILE__ )
|
||||
<< qTableName( "qxmltest", __FILE__ )
|
||||
<< qTableName( "qtest_exerr", __FILE__ )
|
||||
<< qTableName( "qtest_empty", __FILE__ )
|
||||
<< qTableName( "clobby", __FILE__ )
|
||||
<< qTableName( "bindtest", __FILE__ )
|
||||
<< qTableName( "more_results", __FILE__ )
|
||||
<< qTableName( "blobstest", __FILE__ )
|
||||
<< qTableName( "oraRowId", __FILE__ )
|
||||
<< qTableName( "qtest_batch", __FILE__ )
|
||||
<< qTableName("bug6421", __FILE__).toUpper()
|
||||
<< qTableName("bug5765", __FILE__)
|
||||
<< qTableName("bug6852", __FILE__)
|
||||
<< qTableName( "qtest_lockedtable", __FILE__ )
|
||||
<< qTableName( "Planet", __FILE__ )
|
||||
<< qTableName( "task_250026", __FILE__ )
|
||||
<< qTableName( "task_234422", __FILE__ )
|
||||
<< qTableName("test141895", __FILE__)
|
||||
<< qTableName("qtest_oraOCINumber", __FILE__);
|
||||
<< qTableName("qtest_null", __FILE__, db)
|
||||
<< qTableName("qtest_blob", __FILE__, db)
|
||||
<< qTableName("qtest_bittest", __FILE__, db)
|
||||
<< qTableName("qtest_nullblob", __FILE__, db)
|
||||
<< qTableName("qtest_rawtest", __FILE__, db)
|
||||
<< qTableName("qtest_precision", __FILE__, db)
|
||||
<< qTableName("qtest_prepare", __FILE__, db)
|
||||
<< qTableName("qtestj1", __FILE__, db)
|
||||
<< qTableName("qtestj2", __FILE__, db)
|
||||
<< qTableName("char1Select", __FILE__, db)
|
||||
<< qTableName("char1SU", __FILE__, db)
|
||||
<< qTableName("qxmltest", __FILE__, db)
|
||||
<< qTableName("qtest_exerr", __FILE__, db)
|
||||
<< qTableName("qtest_empty", __FILE__, db)
|
||||
<< qTableName("clobby", __FILE__, db)
|
||||
<< qTableName("bindtest", __FILE__, db)
|
||||
<< qTableName("more_results", __FILE__, db)
|
||||
<< qTableName("blobstest", __FILE__, db)
|
||||
<< qTableName("oraRowId", __FILE__, db)
|
||||
<< qTableName("qtest_batch", __FILE__, db)
|
||||
<< qTableName("bug6421", __FILE__, db).toUpper()
|
||||
<< qTableName("bug5765", __FILE__, db)
|
||||
<< qTableName("bug6852", __FILE__, db)
|
||||
<< qTableName("qtest_lockedtable", __FILE__, db)
|
||||
<< qTableName("Planet", __FILE__, db)
|
||||
<< qTableName("task_250026", __FILE__, db)
|
||||
<< qTableName("task_234422", __FILE__, db)
|
||||
<< qTableName("test141895", __FILE__, db)
|
||||
<< qTableName("qtest_oraOCINumber", __FILE__, db);
|
||||
|
||||
if ( db.driverName().startsWith("QPSQL") )
|
||||
tablenames << qTableName("task_233829", __FILE__);
|
||||
tablenames << qTableName("task_233829", __FILE__, db);
|
||||
|
||||
if ( db.driverName().startsWith("QSQLITE") )
|
||||
tablenames << qTableName( "record_sqlite", __FILE__ );
|
||||
tablenames << qTableName("record_sqlite", __FILE__, db);
|
||||
|
||||
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) )
|
||||
tablenames << qTableName( "qtest_longstr", __FILE__ );
|
||||
tablenames << qTableName("qtest_longstr", __FILE__, db);
|
||||
|
||||
if (tst_Databases::isSqlServer( db ))
|
||||
db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__));
|
||||
db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db));
|
||||
|
||||
if (tst_Databases::isMySQL( db ))
|
||||
db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__));
|
||||
db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__, db));
|
||||
|
||||
tst_Databases::safeDropTables( db, tablenames );
|
||||
|
||||
if ( db.driverName().startsWith( "QOCI" ) ) {
|
||||
QSqlQuery q( db );
|
||||
q.exec( "DROP PACKAGE " + qTableName("pkg", __FILE__) );
|
||||
q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db));
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,15 +219,15 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db )
|
||||
QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) );
|
||||
|
||||
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
|
||||
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int null, t_varchar varchar(20) null)" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int null, t_varchar varchar(20) null)" ) );
|
||||
else
|
||||
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int, t_varchar varchar(20))" ) );
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int, t_varchar varchar(20))" ) );
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::populateTestTables( QSqlDatabase db )
|
||||
{
|
||||
QSqlQuery q( db );
|
||||
const QString qtest_null(qTableName( "qtest_null", __FILE__ ));
|
||||
const QString qtest_null(qTableName("qtest_null", __FILE__, db));
|
||||
q.exec( "delete from " + qtest );
|
||||
QVERIFY_SQL( q, exec( "insert into " + qtest + " values (1, 'VarChar1', 'Char1')" ) );
|
||||
QVERIFY_SQL( q, exec( "insert into " + qtest + " values (2, 'VarChar2', 'Char2')" ) );
|
||||
@ -251,7 +251,7 @@ void tst_QSqlQuery::benchmark()
|
||||
QSKIP( "Test requires MySQL >= 5.0");
|
||||
|
||||
QSqlQuery q(db);
|
||||
const QString tableName(qTableName("benchmark", __FILE__));
|
||||
const QString tableName(qTableName("benchmark", __FILE__, db));
|
||||
|
||||
tst_Databases::safeDropTable( db, tableName );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user