Interbase: Fix tests when running against Firebird
Change-Id: Ibfcf6b557aed3b0cd2e0ece5cf122819a1acc0c1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
aa2c6690fd
commit
7ec818e74a
@ -67,9 +67,6 @@ static QString qGetHostName()
|
||||
return hostname;
|
||||
}
|
||||
|
||||
// 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 QString fixupTableName(const QString &tableName, QSqlDatabase db)
|
||||
{
|
||||
QString tbName = tableName;
|
||||
@ -77,16 +74,21 @@ inline QString fixupTableName(const QString &tableName, QSqlDatabase db)
|
||||
QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
|
||||
if (d && d->dbmsType == QSqlDriver::Oracle)
|
||||
tbName.truncate(30);
|
||||
// On Interbase we are limited to 31 character tablenames
|
||||
if (d && d->dbmsType == QSqlDriver::Interbase)
|
||||
tbName.truncate(31);
|
||||
return tbName;
|
||||
}
|
||||
|
||||
// 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,
|
||||
QSqlDatabase db, bool escape = true)
|
||||
{
|
||||
const auto tableStr = fixupTableName(QString(QLatin1String("dbtst") + db.driverName() +
|
||||
QString::number(qHash(QLatin1String(sourceFileName) +
|
||||
"_" + qGetHostName().replace("-", "_")), 16) +
|
||||
"_" + prefix), db);
|
||||
const auto tableStr = fixupTableName(QString(QLatin1String("dbtst") + db.driverName() + "_" +
|
||||
prefix + QString::number(qHash(QLatin1String(sourceFileName) +
|
||||
"_" + qGetHostName().replace("-", "_")), 16)), db);
|
||||
return escape ? db.driver()->escapeIdentifier(tableStr, QSqlDriver::TableName) : tableStr;
|
||||
}
|
||||
|
||||
@ -452,6 +454,8 @@ public:
|
||||
return QLatin1String("timestamptz");
|
||||
if (dbType == QSqlDriver::Oracle && getOraVersion(db) >= 9)
|
||||
return QLatin1String("timestamp(0)");
|
||||
if (dbType == QSqlDriver::Interbase)
|
||||
return QLatin1String("timestamp");
|
||||
return QLatin1String("datetime");
|
||||
}
|
||||
|
||||
|
@ -279,6 +279,13 @@ static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db)
|
||||
return i;
|
||||
}
|
||||
|
||||
bool driverQuotedCaseSensitive(QSqlDatabase db)
|
||||
{
|
||||
// On Interbase it will be case sensitive if it was created with quotes
|
||||
QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
|
||||
return (d && d->dbmsType == QSqlDriver::Interbase);
|
||||
}
|
||||
|
||||
tst_QSqlDatabase::tst_QSqlDatabase()
|
||||
{
|
||||
}
|
||||
@ -575,8 +582,13 @@ void tst_QSqlDatabase::whitespaceInIdentifiers()
|
||||
const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
|
||||
|
||||
if (testWhiteSpaceNames(db.driverName())) {
|
||||
const auto tableName(qTableName("qtest test", __FILE__, db, false));
|
||||
QVERIFY(db.tables().contains(tableName, Qt::CaseInsensitive));
|
||||
const bool isCaseSensitive = driverQuotedCaseSensitive(db);
|
||||
const auto tableName(qTableName("qtest test", __FILE__, db, isCaseSensitive));
|
||||
if (isCaseSensitive) {
|
||||
QVERIFY(db.tables().contains(db.driver()->stripDelimiters(tableName, QSqlDriver::TableName)));
|
||||
} else {
|
||||
QVERIFY(db.tables().contains(tableName, Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
QSqlRecord rec = db.record(tableName);
|
||||
QCOMPARE(rec.count(), 1);
|
||||
@ -605,11 +617,11 @@ void tst_QSqlDatabase::alterTable()
|
||||
CHECK_DATABASE(db);
|
||||
const QString qtestalter(qTableName("qtestalter", __FILE__, db));
|
||||
const auto noEscapeAlterTable = qTableName("qtestalter", __FILE__, db, false);
|
||||
|
||||
const bool isCaseSensitive = driverQuotedCaseSensitive(db);
|
||||
QSqlQuery q(db);
|
||||
|
||||
QVERIFY_SQL(q, exec("create table " + qtestalter + " (F1 char(20), F2 char(20), F3 char(20))"));
|
||||
QSqlRecord rec = db.record(noEscapeAlterTable);
|
||||
QSqlRecord rec = db.record(isCaseSensitive ? qtestalter : noEscapeAlterTable);
|
||||
QCOMPARE((int)rec.count(), 3);
|
||||
|
||||
int i;
|
||||
@ -621,7 +633,7 @@ void tst_QSqlDatabase::alterTable()
|
||||
QSKIP("DBMS doesn't support dropping columns in ALTER TABLE statement");
|
||||
}
|
||||
|
||||
rec = db.record(noEscapeAlterTable);
|
||||
rec = db.record(isCaseSensitive ? qtestalter : noEscapeAlterTable);
|
||||
|
||||
QCOMPARE((int)rec.count(), 2);
|
||||
|
||||
@ -679,8 +691,11 @@ void tst_QSqlDatabase::testRecord(const FieldDef fieldDefs[], const QSqlRecord&
|
||||
void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase db, const int fieldCount)
|
||||
{
|
||||
CHECK_DATABASE(db);
|
||||
const QStringList tableNames = { qTableName("qtestfields", __FILE__, db),
|
||||
qTableName("qtestfields", __FILE__, db, false) };
|
||||
|
||||
QStringList tableNames = { qTableName("qtestfields", __FILE__, db) };
|
||||
if (!driverQuotedCaseSensitive(db))
|
||||
tableNames << qTableName("qtestfields", __FILE__, db, false);
|
||||
|
||||
for (const QString &table : tableNames) {
|
||||
QSqlRecord rec = db.record(table);
|
||||
QCOMPARE(rec.count(), fieldCount + 1);
|
||||
@ -1204,10 +1219,12 @@ void tst_QSqlDatabase::caseSensivity()
|
||||
bool cs = false;
|
||||
if (dbType == QSqlDriver::MySqlServer || dbType == QSqlDriver::SQLite
|
||||
|| dbType == QSqlDriver::Sybase || dbType == QSqlDriver::PostgreSQL
|
||||
|| dbType == QSqlDriver::MSSqlServer || db.driverName().startsWith("QODBC"))
|
||||
cs = true;
|
||||
|| dbType == QSqlDriver::MSSqlServer || db.driverName().startsWith("QODBC")
|
||||
|| dbType == QSqlDriver::Interbase) {
|
||||
cs = true;
|
||||
}
|
||||
|
||||
QSqlRecord rec = db.record(qTableName("qtest", __FILE__, db, false));
|
||||
QSqlRecord rec = db.record(qTableName("qtest", __FILE__, db, driverQuotedCaseSensitive(db)));
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
if (!cs) {
|
||||
rec = db.record(qTableName("QTEST", __FILE__, db, false).toUpper());
|
||||
@ -1216,7 +1233,7 @@ void tst_QSqlDatabase::caseSensivity()
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
}
|
||||
|
||||
rec = db.primaryIndex(qTableName("qtest", __FILE__, db, false));
|
||||
rec = db.primaryIndex(qTableName("qtest", __FILE__, db, driverQuotedCaseSensitive(db)));
|
||||
QVERIFY((int)rec.count() > 0);
|
||||
if (!cs) {
|
||||
rec = db.primaryIndex(qTableName("QTEST", __FILE__, db, false).toUpper());
|
||||
@ -1908,6 +1925,8 @@ void tst_QSqlDatabase::ibase_useCustomCharset()
|
||||
const QString tableName(qTableName("latin1table", __FILE__, db));
|
||||
|
||||
QSqlQuery q(db);
|
||||
QEXPECT_FAIL("", "Currently fails, potentially due to invalid test - needs further "
|
||||
"investigation - QTBUG-85828", Abort);
|
||||
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(text VARCHAR(6) CHARACTER SET Latin1)").arg(tableName)));
|
||||
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName)));
|
||||
q.addBindValue(nonlatin1string);
|
||||
|
@ -91,6 +91,8 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
|
||||
doubleField = "more_data number(8,7)";
|
||||
else if (dbType == QSqlDriver::PostgreSQL)
|
||||
doubleField = "more_data double precision";
|
||||
else if (dbType == QSqlDriver::Interbase)
|
||||
doubleField = "more_data numeric(8,7)";
|
||||
else
|
||||
doubleField = "more_data double(8,7)";
|
||||
const QString defValue(driverSupportsDefaultValues(dbType) ? QStringLiteral("DEFAULT 'defaultVal'") : QString());
|
||||
@ -157,7 +159,7 @@ void tst_QSqlDriver::record()
|
||||
if (driverSupportsDefaultValues(dbType))
|
||||
QCOMPARE(rec.field(QStringLiteral("name")).defaultValue().toString(), QStringLiteral("defaultVal"));
|
||||
|
||||
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2)
|
||||
if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2)
|
||||
tablename = tablename.toUpper();
|
||||
else if (dbType == QSqlDriver::PostgreSQL)
|
||||
tablename = tablename.toLower();
|
||||
@ -205,7 +207,7 @@ void tst_QSqlDriver::primaryIndex()
|
||||
|
||||
|
||||
//check that we can get the primary index using a quoted tablename
|
||||
if (dbType == QSqlDriver::Interbase || dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2)
|
||||
if (dbType == QSqlDriver::Oracle || dbType == QSqlDriver::DB2)
|
||||
tablename = tablename.toUpper();
|
||||
else if (dbType == QSqlDriver::PostgreSQL)
|
||||
tablename = tablename.toLower();
|
||||
|
@ -845,16 +845,17 @@ void tst_QSqlQuery::storedProceduresIBase()
|
||||
CHECK_DATABASE( db );
|
||||
|
||||
QSqlQuery q( db );
|
||||
q.exec("drop procedure " + qTableName("TESTPROC", __FILE__, db));
|
||||
const auto procName = qTableName("TESTPROC", __FILE__, db);
|
||||
q.exec("drop procedure " + procName);
|
||||
|
||||
QVERIFY_SQL(q, exec("create procedure " + qTableName("TESTPROC", __FILE__, db) +
|
||||
QVERIFY_SQL(q, exec("create procedure " + procName +
|
||||
" RETURNS (x integer, y varchar(20)) "
|
||||
"AS BEGIN "
|
||||
" x = 42; "
|
||||
" y = 'Hello Anders'; "
|
||||
"END" ) );
|
||||
|
||||
QVERIFY_SQL(q, prepare("execute procedure " + qTableName("TestProc", __FILE__, db)));
|
||||
QVERIFY_SQL(q, prepare("execute procedure " + procName));
|
||||
QVERIFY_SQL( q, exec() );
|
||||
|
||||
// check for a valid result set
|
||||
@ -871,7 +872,7 @@ void tst_QSqlQuery::storedProceduresIBase()
|
||||
// the second next shall fail
|
||||
QVERIFY( !q.next() );
|
||||
|
||||
q.exec("drop procedure " + qTableName("TestProc", __FILE__, db));
|
||||
q.exec("drop procedure " + procName);
|
||||
}
|
||||
|
||||
void tst_QSqlQuery::outValuesDB2()
|
||||
@ -2467,9 +2468,18 @@ void tst_QSqlQuery::batchExec()
|
||||
QSqlQuery q( db );
|
||||
const QString tableName = qTableName("qtest_batch", __FILE__, db);
|
||||
tst_Databases::safeDropTable(db, tableName);
|
||||
|
||||
const auto dbType = tst_Databases::getDatabaseType(db);
|
||||
QString timeStampString;
|
||||
if (dbType == QSqlDriver::Interbase)
|
||||
timeStampString = QLatin1String("TIMESTAMP");
|
||||
else
|
||||
timeStampString = QLatin1String("TIMESTAMP (3)");
|
||||
|
||||
QVERIFY_SQL(q, exec(QStringLiteral("create table ") + tableName +
|
||||
QStringLiteral(" (id int, name varchar(20), dt date, num numeric(8, 4), "
|
||||
"dtstamp TIMESTAMP(3), extraId int, extraName varchar(20))")));
|
||||
"dtstamp ") + timeStampString +
|
||||
QStringLiteral(", extraId int, extraName varchar(20))")));
|
||||
|
||||
const QVariantList intCol = { 1, 2, QVariant(QVariant::Int) };
|
||||
const QVariantList charCol = { QStringLiteral("harald"), QStringLiteral("boris"),
|
||||
@ -3357,6 +3367,11 @@ void tst_QSqlQuery::timeStampParsing()
|
||||
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
|
||||
"id integer NOT NULL AUTO_INCREMENT,"
|
||||
"datefield timestamp, primary key(id));")));
|
||||
} else if (dbType == QSqlDriver::Interbase) {
|
||||
// Since there is no auto-increment feature in Interbase we allow it to be null
|
||||
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
|
||||
"id integer,"
|
||||
"datefield timestamp);")));
|
||||
} else {
|
||||
QVERIFY_SQL(q, exec(QStringLiteral("CREATE TABLE ") + tableName + QStringLiteral("("
|
||||
"\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT,"
|
||||
@ -4273,7 +4288,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
||||
QVariant::Type countType = intType;
|
||||
// QPSQL uses LongLong for manipulation of integers
|
||||
const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
|
||||
if (dbType == QSqlDriver::PostgreSQL) {
|
||||
if (dbType == QSqlDriver::PostgreSQL || dbType == QSqlDriver::Interbase) {
|
||||
sumType = countType = QVariant::LongLong;
|
||||
} else if (dbType == QSqlDriver::Oracle) {
|
||||
intType = sumType = countType = QVariant::Double;
|
||||
@ -4312,7 +4327,7 @@ void tst_QSqlQuery::aggregateFunctionTypes()
|
||||
QCOMPARE(q.record().field(0).metaType().id(), QVariant::Double);
|
||||
} else {
|
||||
QCOMPARE(q.value(0).toInt(), 1);
|
||||
QCOMPARE(q.record().field(0).metaType().id(), QVariant::Int);
|
||||
QCOMPARE(q.record().field(0).metaType().id(), (dbType == QSqlDriver::Interbase ? QVariant::LongLong : QVariant::Int));
|
||||
}
|
||||
|
||||
QVERIFY_SQL(q, exec("SELECT COUNT(id) FROM " + tableName));
|
||||
|
@ -34,9 +34,6 @@
|
||||
|
||||
#include "../../kernel/qsqldatabase/tst_databases.h"
|
||||
|
||||
QString reltest1;
|
||||
QString reltest2;
|
||||
|
||||
class tst_QSqlRelationalDelegate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -62,11 +59,6 @@ private:
|
||||
|
||||
tst_QSqlRelationalDelegate::tst_QSqlRelationalDelegate()
|
||||
{
|
||||
static QSqlDatabase static_qtest_db_1 = QSqlDatabase();
|
||||
reltest1 = qTableName("reltest1", __FILE__, static_qtest_db_1);
|
||||
|
||||
static QSqlDatabase static_qtest_db_2 = QSqlDatabase();
|
||||
reltest2 = qTableName("reltest2", __FILE__, static_qtest_db_2);
|
||||
}
|
||||
|
||||
void tst_QSqlRelationalDelegate::initTestCase_data()
|
||||
@ -78,11 +70,23 @@ void tst_QSqlRelationalDelegate::initTestCase_data()
|
||||
|
||||
void tst_QSqlRelationalDelegate::recreateTestTables(QSqlDatabase db)
|
||||
{
|
||||
const auto reltest1 = qTableName("reltest1", __FILE__, db);
|
||||
const auto reltest2 = qTableName("reltest2", __FILE__, db);
|
||||
|
||||
dropTestTables(db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
const auto idField = db.driver()->escapeIdentifier(QLatin1String("id"), QSqlDriver::FieldName);
|
||||
const auto nameField = db.driver()->escapeIdentifier(QLatin1String("name"), QSqlDriver::FieldName);
|
||||
const auto titleKeyField = db.driver()->escapeIdentifier(QLatin1String("title_key"),
|
||||
QSqlDriver::FieldName);
|
||||
const auto anotherTitleField = db.driver()->escapeIdentifier(QLatin1String("another_title_key"),
|
||||
QSqlDriver::FieldName);
|
||||
const auto titleField = db.driver()->escapeIdentifier(QLatin1String("title"),
|
||||
QSqlDriver::FieldName);
|
||||
QVERIFY_SQL(q, exec("create table " + reltest1 +
|
||||
" (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
|
||||
" (" + idField + " int not null primary key, " + nameField + " varchar(20), " +
|
||||
titleKeyField + " int, " + anotherTitleField + "int)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest1 + " values(1, 'harry', 1, 2)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest1 + " values(2, 'trond', 2, 1)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest1 + " values(3, 'vohi', 1, 2)"));
|
||||
@ -90,7 +94,8 @@ void tst_QSqlRelationalDelegate::recreateTestTables(QSqlDatabase db)
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest1 + " values(5, 'nat', NULL, NULL)"));
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest1 + " values(6, 'ale', NULL, 2)"));
|
||||
|
||||
QVERIFY_SQL(q, exec("create table " + reltest2 + " (id int not null primary key, title varchar(20))"));
|
||||
QVERIFY_SQL(q, exec("create table " + reltest2 + " (" + idField + " int not null primary key, "
|
||||
+ titleKeyField + " varchar(20))"));
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest2 + " values(1, 'herr')"));
|
||||
QVERIFY_SQL(q, exec("insert into " + reltest2 + " values(2, 'mister')"));
|
||||
}
|
||||
@ -124,7 +129,7 @@ void tst_QSqlRelationalDelegate::cleanupTestCase()
|
||||
|
||||
void tst_QSqlRelationalDelegate::dropTestTables(QSqlDatabase db)
|
||||
{
|
||||
QStringList tableNames = { reltest1, reltest2 };
|
||||
QStringList tableNames = { qTableName("reltest1", __FILE__, db), qTableName("reltest2", __FILE__, db) };
|
||||
tst_Databases::safeDropTables(db, tableNames);
|
||||
}
|
||||
|
||||
@ -142,12 +147,18 @@ void tst_QSqlRelationalDelegate::comboBoxEditor()
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
|
||||
const auto reltest1 = qTableName("reltest1", __FILE__, db);
|
||||
const auto reltest2 = qTableName("reltest2", __FILE__, db);
|
||||
const auto idField = db.driver()->escapeIdentifier(QLatin1String("id"), QSqlDriver::FieldName);
|
||||
const auto nameField = db.driver()->escapeIdentifier(QLatin1String("name"), QSqlDriver::FieldName);
|
||||
const auto titleKeyField = db.driver()->escapeIdentifier(QLatin1String("title_key"),
|
||||
QSqlDriver::FieldName);
|
||||
QTableView tv;
|
||||
QSqlRelationalTableModel model(0, db);
|
||||
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
model.setTable(reltest1);
|
||||
model.setRelation(2, QSqlRelation(reltest2, "id", "title"));
|
||||
model.setRelation(3, QSqlRelation(reltest2, "id", "title"));
|
||||
model.setRelation(2, QSqlRelation(reltest2, idField, titleKeyField));
|
||||
model.setRelation(3, QSqlRelation(reltest2, idField, titleKeyField));
|
||||
tv.setModel(&model);
|
||||
QVERIFY_SQL(model, select());
|
||||
|
||||
@ -171,7 +182,7 @@ void tst_QSqlRelationalDelegate::comboBoxEditor()
|
||||
QVERIFY_SQL(model, submitAll());
|
||||
|
||||
QSqlQuery qry(db);
|
||||
QVERIFY_SQL(qry, exec("SELECT title_key FROM " + reltest1 + " WHERE id=1"));
|
||||
QVERIFY_SQL(qry, exec("SELECT " + titleKeyField + " FROM " + reltest1 + " WHERE " + idField + "=1"));
|
||||
QVERIFY(qry.next());
|
||||
QCOMPARE(qry.value(0).toString(), "2");
|
||||
}
|
||||
|
@ -34,10 +34,6 @@
|
||||
#include <QThread>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
QString test;
|
||||
QString test2;
|
||||
QString test3;
|
||||
|
||||
// In order to catch when the warning message occurs, indicating that the database belongs to another
|
||||
// thread, we have to install our own message handler. To ensure that the test reporting still happens
|
||||
// as before, we call the originating one.
|
||||
@ -164,16 +160,6 @@ private:
|
||||
|
||||
tst_QSqlTableModel::tst_QSqlTableModel()
|
||||
{
|
||||
static QSqlDatabase static_qtest_db_1 = QSqlDatabase();
|
||||
test = qTableName("test1", __FILE__, static_qtest_db_1);
|
||||
|
||||
static QSqlDatabase static_qtest_db_2 = QSqlDatabase();
|
||||
test2 = qTableName("test2", __FILE__, static_qtest_db_2);
|
||||
|
||||
static QSqlDatabase static_qtest_db_3 = QSqlDatabase();
|
||||
test3 = qTableName("test3", __FILE__, static_qtest_db_3);
|
||||
|
||||
QVERIFY(dbs.open());
|
||||
}
|
||||
|
||||
tst_QSqlTableModel::~tst_QSqlTableModel()
|
||||
@ -190,9 +176,9 @@ void tst_QSqlTableModel::dropTestTables()
|
||||
QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
|
||||
|
||||
QStringList tableNames;
|
||||
tableNames << test
|
||||
<< test2
|
||||
<< test3
|
||||
tableNames << qTableName("test1", __FILE__, db)
|
||||
<< qTableName("test2", __FILE__, db)
|
||||
<< qTableName("test3", __FILE__, db)
|
||||
<< qTableName("test4", __FILE__, db)
|
||||
<< qTableName("emptytable", __FILE__, db)
|
||||
<< qTableName("bigtable", __FILE__, db)
|
||||
@ -216,11 +202,11 @@ void tst_QSqlTableModel::createTestTables()
|
||||
QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
|
||||
QSqlQuery q(db);
|
||||
|
||||
QVERIFY_SQL( q, exec("create table " + test + "(id int, name varchar(20), title int)"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test1", __FILE__, db) + "(id int, name varchar(20), title int)"));
|
||||
|
||||
QVERIFY_SQL( q, exec("create table " + test2 + "(id int, title varchar(20))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__, db) + "(id int, title varchar(20))"));
|
||||
|
||||
QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))"));
|
||||
QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__, db) + "(id int, random varchar(20), randomtwo varchar(20))"));
|
||||
|
||||
if (dbType != QSqlDriver::MSSqlServer)
|
||||
QVERIFY_SQL(q, exec("create table " + qTableName("test4", __FILE__, db) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))"));
|
||||
@ -244,6 +230,9 @@ void tst_QSqlTableModel::repopulateTestTables()
|
||||
for (int i = 0; i < dbs.dbNames.count(); ++i) {
|
||||
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
|
||||
QSqlQuery q(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
const auto test2 = qTableName("test2", __FILE__, db);
|
||||
const auto test3 = qTableName("test3", __FILE__, db);
|
||||
|
||||
q.exec("delete from " + test);
|
||||
QVERIFY_SQL( q, exec("insert into " + test + " values(1, 'harry', 1)"));
|
||||
@ -316,6 +305,7 @@ void tst_QSqlTableModel::select()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -462,6 +452,7 @@ void tst_QSqlTableModel::insertColumns()
|
||||
QSqlTableModel::EditStrategy submitpolicy = (QSqlTableModel::EditStrategy) submitpolicy_i;
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -534,6 +525,7 @@ void tst_QSqlTableModel::setData()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
@ -605,6 +597,7 @@ void tst_QSqlTableModel::setRecord()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test3 = qTableName("test3", __FILE__, db);
|
||||
|
||||
QList<QSqlTableModel::EditStrategy> policies = QList<QSqlTableModel::EditStrategy>() << QSqlTableModel::OnFieldChange << QSqlTableModel::OnRowChange << QSqlTableModel::OnManualSubmit;
|
||||
|
||||
@ -676,6 +669,8 @@ void tst_QSqlTableModel::setRecordReimpl()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test3 = qTableName("test3", __FILE__, db);
|
||||
|
||||
SetRecordReimplModel model(0, db);
|
||||
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
model.setTable(test3);
|
||||
@ -712,6 +707,8 @@ void tst_QSqlTableModel::recordReimpl()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test3 = qTableName("test3", __FILE__, db);
|
||||
|
||||
RecordReimplModel model(0, db);
|
||||
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
model.setTable(test3);
|
||||
@ -739,6 +736,7 @@ void tst_QSqlTableModel::insertRow()
|
||||
QSqlTableModel::EditStrategy submitpolicy = (QSqlTableModel::EditStrategy) submitpolicy_i;
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setEditStrategy(submitpolicy);
|
||||
@ -912,6 +910,7 @@ void tst_QSqlTableModel::insertRecord()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
@ -945,6 +944,7 @@ void tst_QSqlTableModel::insertMultiRecords()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
@ -1060,6 +1060,7 @@ void tst_QSqlTableModel::submitAll()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1095,6 +1096,7 @@ void tst_QSqlTableModel::removeRow()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1143,6 +1145,7 @@ void tst_QSqlTableModel::removeRows()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1216,6 +1219,7 @@ void tst_QSqlTableModel::removeInsertedRow()
|
||||
QSqlTableModel::EditStrategy submitpolicy = (QSqlTableModel::EditStrategy) submitpolicy_i;
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1279,6 +1283,7 @@ void tst_QSqlTableModel::removeInsertedRows()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1476,6 +1481,7 @@ void tst_QSqlTableModel::isDirty()
|
||||
QSqlTableModel::EditStrategy submitpolicy = (QSqlTableModel::EditStrategy) submitpolicy_i;
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setEditStrategy(submitpolicy);
|
||||
@ -1760,6 +1766,7 @@ void tst_QSqlTableModel::setInvalidFilter()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
// set an invalid filter, make sure it fails
|
||||
QSqlTableModel model(0, db);
|
||||
@ -1779,6 +1786,7 @@ void tst_QSqlTableModel::setFilter()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1844,6 +1852,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -1914,6 +1923,7 @@ void tst_QSqlTableModel::insertRecordsInLoop()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -2053,6 +2063,7 @@ void tst_QSqlTableModel::removeColumnAndRow()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
@ -2081,6 +2092,7 @@ void tst_QSqlTableModel::insertBeforeDelete()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlQuery q(db);
|
||||
QVERIFY_SQL( q, exec("insert into " + test + " values(9, 'andrew', 9)"));
|
||||
@ -2107,6 +2119,7 @@ void tst_QSqlTableModel::invalidFilterAndHeaderData()
|
||||
QFETCH(QString, dbName);
|
||||
QSqlDatabase db = QSqlDatabase::database(dbName);
|
||||
CHECK_DATABASE(db);
|
||||
const auto test = qTableName("test1", __FILE__, db);
|
||||
|
||||
QSqlTableModel model(0, db);
|
||||
model.setTable(test);
|
||||
|
Loading…
Reference in New Issue
Block a user