Hi All,

My team were previously using Qt 4.3 and are trying to update to the latest release (4.7.2).

Before we were using the qsqlite plugin, but this functionality has been moved into the main QSql component of Qt.

Now that we have upgraded, we're unable to read our old databases. This seems to be because when we created our tables, we created them like this:

Qt Code:
  1. CREATE TABLE [Characters] ([Id] INTEGER NOT NULL ON CONFLICT ROLLBACK PRIMARY KEY ON CONFLICT ROLLBACK AUTOINCREMENT UNIQUE ON CONFLICT ROLLBACK,
  2. [Project_Id] INTEGER NOT NULL ON CONFLICT ROLLBACK REFERENCES [Projects](Id) ON DELETE RESTRICT ON UPDATE RESTRICT ON INSERT RESTRICT,
  3. [CharacterName] VARCHAR(128) NOT NULL ON CONFLICT ROLLBACK UNIQUE ON CONFLICT ROLLBACK);
To copy to clipboard, switch view to plain text mode 
but ON INSERT RESTRICT is no longer valid.

I was able to remove that code and create new tables, but if I do myQSqlDatabase.tables() on one of the existing DBs, it returns zero.

I noticed by digging into the Qt code, that the prepare method has:

Qt Code:
  1. #if (SQLITE_VERSION_NUMBER >= 3003011)
  2. int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, 0);
  3. #else
  4. int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, 0);
  5. #endif
To copy to clipboard, switch view to plain text mode 
and we are entering the first if (sqlite3_prepare16_v2).

Should we be defining SQLITE_VERSION_NUMBER somewhere to be lower? Is there something else that we're doing wrong to prevent backwards compatibility?

Any help would be appreciated.

Thanks, Liron