← Back to team overview

uonedb-qt team mailing list archive

[Merge] lp:~kalikiana/u1db-qt/removeDoc into lp:u1db-qt

 

Christian Dywan has proposed merging lp:~kalikiana/u1db-qt/removeDoc into lp:u1db-qt.

Commit message:
Implement Database.removeDoc method and use it in unit test

Functionally this is equivalent to replacing the doc with an empty one.

Requested reviews:
  PS Jenkins bot (ps-jenkins): continuous-integration
  U1DB Qt developers (uonedb-qt)
Related bugs:
  Bug #1243395 in U1DB Qt/ QML: "Need API to delete documents from QML"
  https://bugs.launchpad.net/u1db-qt/+bug/1243395

For more details, see:
https://code.launchpad.net/~kalikiana/u1db-qt/removeDoc/+merge/196301
-- 
https://code.launchpad.net/~kalikiana/u1db-qt/removeDoc/+merge/196301
Your team U1DB Qt developers is requested to review the proposed merge of lp:~kalikiana/u1db-qt/removeDoc into lp:u1db-qt.
=== modified file 'src/database.cpp'
--- src/database.cpp	2013-08-14 12:07:11 +0000
+++ src/database.cpp	2013-11-22 15:24:45 +0000
@@ -658,6 +658,15 @@
 }
 
 /*!
+    Removes the document identified by \a docId.
+ */
+void
+Database::removeDoc(const QString& docId)
+{
+    putDoc(QString(), docId);
+}
+
+/*!
  * \brief Database::resetModel
  *
  * Resets the Database model.

=== modified file 'src/database.h'
--- src/database.h	2013-08-12 15:28:13 +0000
+++ src/database.h	2013-11-22 15:24:45 +0000
@@ -49,6 +49,7 @@
     QString getDocumentContents(const QString& docId);
     QVariant getDocUnchecked(const QString& docId) const;
     Q_INVOKABLE QString putDoc(QVariant newDoc, const QString& docID=QString());
+    Q_INVOKABLE void removeDoc(const QString& docID);
     Q_INVOKABLE QList<QString> listDocs();
     Q_INVOKABLE QString lastError();
     Q_INVOKABLE QString putIndex(const QString& index_name, QStringList expressions);

=== modified file 'tests/tst_query.qml'
--- tests/tst_query.qml	2013-08-27 10:49:26 +0000
+++ tests/tst_query.qml	2013-11-22 15:24:45 +0000
@@ -182,7 +182,7 @@
     function test_4_delete () {
         compare(defaultPhone.documents, ['1', '_', 'a'], 'uno')
         // Deleted aka empty documents should not be returned
-        gents.putDoc('', '_')
+        gents.removeDoc('_')
         compare(defaultPhone.documents, ['1', 'a'], 'dos')
     }
 


Follow ups