From e8e236cab6c88a7981453870126e6dadf60d01e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moses=20Palm=C3=A9r?= Date: Mon, 29 Aug 2011 22:16:19 +0200 Subject: [PATCH] Correctly interpret documents with IDs beginning with "_design/" couchdb_database_get_document should return a CouchdbDesignDocument if the ID begins with "_design/". The database watcher calls couchdb_database_get_document to check whether a document still exists, and if that function does not fall back on couchdb_database_get_design_document, changed design documents will always be considered to be removed. --- couchdb-glib/couchdb-database.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/couchdb-glib/couchdb-database.c b/couchdb-glib/couchdb-database.c index 8706d8d..05d081d 100644 --- a/couchdb-glib/couchdb-database.c +++ b/couchdb-glib/couchdb-database.c @@ -546,6 +546,11 @@ couchdb_database_get_document (CouchdbDatabase *database, g_return_val_if_fail (COUCHDB_IS_DATABASE (database), NULL); g_return_val_if_fail (docid != NULL, NULL); + /* If the ID begins with "_design/", return a CouchdbDesignDocument */ + if (g_str_has_prefix (docid, "_design/")) { + return COUCHDB_DOCUMENT(couchdb_database_get_design_document(database, docid, error)); + } + encoded_docid = soup_uri_encode (docid, NULL); url = g_strdup_printf ("%s/%s/%s", couchdb_session_get_uri (database->priv->session), database->priv->dbname, encoded_docid); -- 1.7.4.1