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

Proposed by Cris Dywan
Status: Merged
Approved by: Cris Dywan
Approved revision: 110
Merged at revision: 110
Proposed branch: lp://qastaging/~kalikiana/u1db-qt/removeDoc
Merge into: lp://qastaging/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://qastaging/~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.qastaging.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
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: