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

Proposed by Cris Dywan
Status: Merged
Approved by: Cris Dywan
Approved revision: 110
Merged at revision: 110
Proposed branch: lp:~kalikiana/u1db-qt/removeDoc
Merge into: lp:u1db-qt
Diff against target: 43 lines (+11/-1)
3 files modified
src/database.cpp (+9/-0)
src/database.h (+1/-0)
tests/tst_query.qml (+1/-1)
To merge this branch: bzr merge lp:~kalikiana/u1db-qt/removeDoc
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Benjamin Zeller Approve
Review via email: mp+196301@code.launchpad.net

Commit message

Implement Database.removeDoc method and use it in unit test

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

To post a comment you must log in.
Revision history for this message
Kevin Wright (kevin-wright-1) wrote :

Isn't it that documents should always be null or empty and not removed?

If a document is null or empty it should be filtered out in Query or Index
should it not? Those are the mechanisms for filtering results, it seems
maybe the functionality should be there rather than Database, no?
On Nov 22, 2013 4:25 PM, "Christian Dywan" <email address hidden> wrote:

> 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
>
> Requested reviews:
> 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')
> }
>
>
>
> --
> Mailing list: https://launchpad.net/~uonedb-qt
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~uonedb-qt
> More help : https://help.launchpad.net/ListHelp
>
>

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

> Isn't it that documents should always be null or empty and not removed?
>
> If a document is null or empty it should be filtered out in Query or Index
> should it not? Those are the mechanisms for filtering results, it seems
> maybe the functionality should be there rather than Database, no?

There is no functional change in the proposed removeDoc, as you can see in the diff. But as the linked bug shows people are getting confused by the lack of API and it makes it also hard for me as a developer to distinguish between misunderstandings and real bugs.

Revision history for this message
Stuart Langridge (sil) wrote :

The function is called "delete_doc" in the reference implementation. Obviously names should fit the naming scheme of their implementation, but changing "delete_doc" in other implementations to "remove_doc" in the QML implementation seems to be confusing with no benefit.

Revision history for this message
Stuart Langridge (sil) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

Compiles, tests work, changes look fine, good to go

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/database.cpp'
2--- src/database.cpp 2013-08-14 12:07:11 +0000
3+++ src/database.cpp 2014-01-24 11:14:39 +0000
4@@ -658,6 +658,15 @@
5 }
6
7 /*!
8+ Deletes the document identified by \a docId.
9+ */
10+void
11+Database::deleteDoc(const QString& docId)
12+{
13+ putDoc(QString(), docId);
14+}
15+
16+/*!
17 * \brief Database::resetModel
18 *
19 * Resets the Database model.
20
21=== modified file 'src/database.h'
22--- src/database.h 2013-08-12 15:28:13 +0000
23+++ src/database.h 2014-01-24 11:14:39 +0000
24@@ -49,6 +49,7 @@
25 QString getDocumentContents(const QString& docId);
26 QVariant getDocUnchecked(const QString& docId) const;
27 Q_INVOKABLE QString putDoc(QVariant newDoc, const QString& docID=QString());
28+ Q_INVOKABLE void deleteDoc(const QString& docID);
29 Q_INVOKABLE QList<QString> listDocs();
30 Q_INVOKABLE QString lastError();
31 Q_INVOKABLE QString putIndex(const QString& index_name, QStringList expressions);
32
33=== modified file 'tests/tst_query.qml'
34--- tests/tst_query.qml 2013-08-27 10:49:26 +0000
35+++ tests/tst_query.qml 2014-01-24 11:14:39 +0000
36@@ -182,7 +182,7 @@
37 function test_4_delete () {
38 compare(defaultPhone.documents, ['1', '_', 'a'], 'uno')
39 // Deleted aka empty documents should not be returned
40- gents.putDoc('', '_')
41+ gents.deleteDoc('_')
42 compare(defaultPhone.documents, ['1', 'a'], 'dos')
43 }
44

Subscribers

People subscribed via source and target branches

to all changes: