From d5e9616e399e68838f99ae4c123930b330bc4221 Mon Sep 17 00:00:00 2001 From: Matt Newell Date: Thu, 22 Mar 2012 10:42:56 -0700 Subject: Add payload to QSqlDriver notification with PSQL implementation. Postgres async notifications can contain a payload parameter that is currently discarded. This patch provides the QSqlDriver api change necessary to deliver a payload with each emitted notification by adding a QVariant parameter to the notification signal. It also provides the implementation for the qsqlpsql driver. The qsql_ibase driver has been updated to reflect the change to the notification signal signature. The eventNotificationPSQL test in the qsqldatabase test has been expanded to test proper payload sending and receiving. All tests/auto/sql/kernel tests have been run with sqllite and postgres with no regressions. Task-number: QTBUG-13500 Change-Id: I9137f6acc8cfca93f45791ca930e0287d93d5d0d Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 992df6e0b6..626c5049f0 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2069,15 +2069,17 @@ void tst_QSqlDatabase::eventNotificationPSQL() QSqlQuery query(db); QString procedureName = qTableName("posteventProc", __FILE__); + QString payload = "payload"; QSqlDriver &driver=*(db.driver()); QVERIFY_SQL(driver, subscribeToNotification(procedureName)); - QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&,QSqlDriver::NotificationSource))); - query.exec(QString("NOTIFY \"%1\"").arg(procedureName)); + QSignalSpy spy(db.driver(), SIGNAL(notification(const QString&,QSqlDriver::NotificationSource,const QVariant&))); + query.exec(QString("NOTIFY \"%1\", '%2'").arg(procedureName).arg(payload)); QCoreApplication::processEvents(); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toString() == procedureName); - QVERIFY(qVariantValue(arguments.at(1)) == QSqlDriver::SelfSource); + QCOMPARE(arguments.at(0).toString(), procedureName); + QCOMPARE(qVariantValue(arguments.at(1)), QSqlDriver::SelfSource); + QCOMPARE(qvariant_cast(arguments.at(2)).toString(), payload); QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } -- cgit v1.2.3