forked from qt-creator/qt-creator
Sqlite: Improve LastChangedRowId
Sometimes we want not only the row id from one table but two or three. Change-Id: I6d5444a71ecbfe6c1af8073be80b04932ea9268d Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -40,12 +40,43 @@ public:
|
||||
Utils::SmallStringView databaseName,
|
||||
Utils::SmallStringView tableName)
|
||||
: database(database)
|
||||
, databaseName(databaseName)
|
||||
, tableName(tableName)
|
||||
|
||||
{
|
||||
callback = [this](ChangeType, char const *database, char const *table, long long rowId) {
|
||||
if (this->databaseName == database && this->tableName == table)
|
||||
lastRowId = rowId;
|
||||
callback = [=](ChangeType, char const *database, char const *table, long long rowId) {
|
||||
if (databaseName == database && tableName == table)
|
||||
this->lastRowId = rowId;
|
||||
};
|
||||
|
||||
database.setUpdateHook(callback);
|
||||
}
|
||||
|
||||
LastChangedRowId(DatabaseInterface &database,
|
||||
Utils::SmallStringView databaseName,
|
||||
Utils::SmallStringView tableName,
|
||||
Utils::SmallStringView tableName2)
|
||||
: database(database)
|
||||
|
||||
{
|
||||
callback = [=](ChangeType, char const *database, char const *table, long long rowId) {
|
||||
if (databaseName == database && (tableName == table || tableName2 == table))
|
||||
this->lastRowId = rowId;
|
||||
};
|
||||
|
||||
database.setUpdateHook(callback);
|
||||
}
|
||||
|
||||
LastChangedRowId(DatabaseInterface &database,
|
||||
Utils::SmallStringView databaseName,
|
||||
Utils::SmallStringView tableName,
|
||||
Utils::SmallStringView tableName2,
|
||||
Utils::SmallStringView tableName3)
|
||||
: database(database)
|
||||
|
||||
{
|
||||
callback = [=](ChangeType, char const *database, char const *table, long long rowId) {
|
||||
if (databaseName == database
|
||||
&& (tableName == table || tableName2 == table || tableName3 == table))
|
||||
this->lastRowId = rowId;
|
||||
};
|
||||
|
||||
database.setUpdateHook(callback);
|
||||
@@ -63,8 +94,6 @@ public:
|
||||
public:
|
||||
DatabaseInterface &database;
|
||||
DatabaseInterface::UpdateCallback callback;
|
||||
Utils::SmallStringView databaseName;
|
||||
Utils::SmallStringView tableName;
|
||||
long long lastRowId = -1;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user