mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-23 18:42:17 +01:00
Add SQLite Notifier table name getter (#1691)
* Add table name in SQLite Notifier * Converted spaces to tabs to conform to Poco coding style * One more spaces to tab change * Added table compare to Notifier equality operator * Returning const ref instead of string copy in Notifier getTable
This commit is contained in:
parent
61f0bb2c2b
commit
3bacb6696f
@ -137,6 +137,9 @@ public:
|
||||
void setRow(Poco::Int64 row);
|
||||
/// Sets the row number.
|
||||
|
||||
const std::string& getTable() const;
|
||||
/// Returns the table name.
|
||||
|
||||
const Poco::Dynamic::Var& getValue() const;
|
||||
/// Returns the value.
|
||||
|
||||
@ -155,6 +158,7 @@ private:
|
||||
const Session& _session;
|
||||
Poco::Dynamic::Var _value;
|
||||
Poco::Int64 _row;
|
||||
std::string _table;
|
||||
EnabledEventType _enabledEvents;
|
||||
Poco::Mutex _mutex;
|
||||
};
|
||||
@ -168,6 +172,7 @@ inline bool Notifier::operator == (const Notifier& other) const
|
||||
{
|
||||
return _value == other._value &&
|
||||
_row == other._row &&
|
||||
_table == other._table &&
|
||||
Utility::dbHandle(_session) == Utility::dbHandle(other._session);
|
||||
}
|
||||
|
||||
@ -178,6 +183,12 @@ inline Poco::Int64 Notifier::getRow() const
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Notifier::getTable() const
|
||||
{
|
||||
return _table;
|
||||
}
|
||||
|
||||
|
||||
inline void Notifier::setRow(Poco::Int64 row)
|
||||
/// Sets the row number.
|
||||
{
|
||||
|
@ -163,16 +163,19 @@ void Notifier::sqliteUpdateCallbackFn(void* pVal, int opCode, const char* pDB, c
|
||||
if (opCode == Utility::OPERATION_INSERT)
|
||||
{
|
||||
pV->_row = row;
|
||||
pV->_table = pTable;
|
||||
pV->insert.notify(pV);
|
||||
}
|
||||
else if (opCode == Utility::OPERATION_UPDATE)
|
||||
{
|
||||
pV->_row = row;
|
||||
pV->_table = pTable;
|
||||
pV->update.notify(pV);
|
||||
}
|
||||
else if (opCode == Utility::OPERATION_DELETE)
|
||||
{
|
||||
pV->_row = row;
|
||||
pV->_table = pTable;
|
||||
pV->erase.notify(pV);
|
||||
}
|
||||
}
|
||||
|
@ -2886,6 +2886,8 @@ void SQLiteTest::testNotifier()
|
||||
assert (_updateCounter == 3);
|
||||
assert (notifier.getRow() == 3);
|
||||
|
||||
assert (notifier.getTable() == "Person");
|
||||
|
||||
notifier.setRow(0);
|
||||
// SQLite optimizes DELETE so here we must have
|
||||
// the WHERE clause to trigger per-row notifications
|
||||
|
Loading…
x
Reference in New Issue
Block a user