diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-19 07:45:10 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-19 07:45:10 (GMT) |
commit | 27b0c833c18f6b98687937f427887da291184eec (patch) | |
tree | 8c7e18c3181f8dc37b357a3cc88b0978afbe3707 /src/declarative/qml | |
parent | 2b383690c17e1f0f58ad0061fda9d51ff4fe469a (diff) | |
download | Qt-27b0c833c18f6b98687937f427887da291184eec.zip Qt-27b0c833c18f6b98687937f427887da291184eec.tar.gz Qt-27b0c833c18f6b98687937f427887da291184eec.tar.bz2 |
Clean-up SQL tests to not be order-dependent
Add tests for new SQL APIs
Remove some non-useful SQL API extensions.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlsqldatabase.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp index 21ca145..dfe3982 100644 --- a/src/declarative/qml/qmlsqldatabase.cpp +++ b/src/declarative/qml/qmlsqldatabase.cpp @@ -148,13 +148,14 @@ public: return QScriptValue::Undeletable; } - QScriptClassPropertyIterator *newIterator(const QScriptValue &object); + //QScriptClassPropertyIterator *newIterator(const QScriptValue &object); private: QScriptString str_length; QScriptString str_forwardOnly; }; +/* class QmlSqlQueryScriptClassPropertyIterator : public QScriptClassPropertyIterator { public: @@ -223,6 +224,7 @@ QScriptClassPropertyIterator *QmlSqlQueryScriptClass::newIterator(const QScriptV { return new QmlSqlQueryScriptClassPropertyIterator(object); } +*/ enum SqlException { UNKNOWN_ERR, @@ -352,7 +354,9 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri return engine->undefinedValue(); } + bool ok = true; if (callback.isFunction()) { + ok = false; db.transaction(); callback.call(QScriptValue(), QScriptValueList() << tx); if (engine->hasUncaughtException()) { @@ -362,13 +366,17 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri db.rollback(); THROW_SQL(0,QmlEngine::tr("SQL transaction failed")); } else { - context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly); - QSettings ini(databaseFile(db.connectionName(),engine)+QLatin1String(".ini"),QSettings::IniFormat); - ini.setValue(QLatin1String("Version"), to_version); + ok = true; } } } + if (ok) { + context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly); + QSettings ini(databaseFile(db.connectionName(),engine)+QLatin1String(".ini"),QSettings::IniFormat); + ini.setValue(QLatin1String("Version"), to_version); + } + return engine->undefinedValue(); } @@ -442,6 +450,7 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng if (QSqlDatabase::connectionNames().contains(dbid)) { database = QSqlDatabase::database(dbid); + version = ini.value(QLatin1String("Version")).toString(); } else { created = !QFile::exists(basename+QLatin1String(".sqlite")); database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); @@ -459,6 +468,7 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng // Incompatible THROW_SQL(VERSION_ERR,QmlEngine::tr("SQL: database version mismatch")); } + version = ini.value("Version").toString(); } database.setDatabaseName(basename+QLatin1String(".sqlite")); } |