[couchdb-glib] Fix couchdb_database_get_design_documents to use the correct JsonObject when creating CouchdbDesignD



commit 841a874ed3f84d2803308bfb9dfb228214fb9cd6
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Tue Aug 23 13:31:04 2011 +0200

    Fix couchdb_database_get_design_documents to use the correct JsonObject
    when creating CouchdbDesignDocument's
    
    Thanks to Moses PalmÃr (https://bugs.launchpad.net/couchdb-glib/+bug/830273)

 couchdb-glib/couchdb-database.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/couchdb-glib/couchdb-database.c b/couchdb-glib/couchdb-database.c
index 12921e3..f6f9296 100644
--- a/couchdb-glib/couchdb-database.c
+++ b/couchdb-glib/couchdb-database.c
@@ -339,7 +339,7 @@ couchdb_database_get_design_documents (CouchdbDatabase *database, GError **error
 	if (rows != NULL) {
 		gint i;
 		for (i = 0; i < json_array_get_length (rows); i++) {
-			JsonObject *obj;
+			JsonObject *obj, *doc;
 			const gchar *id;
 			CouchdbDesignDocument *document;
 
@@ -347,13 +347,17 @@ couchdb_database_get_design_documents (CouchdbDatabase *database, GError **error
 			if (!obj)
 				continue;
 
-			id = json_object_get_string_member (obj, "_id");
+			doc = json_object_get_object_member (obj, "doc");
+			if (!doc)
+				continue;
+
+			id = json_object_get_string_member (doc, "_id");
 			if (!g_str_has_prefix (id, "_design/"))
 				continue;
 
 			document = couchdb_design_document_new ();
 			if (document != NULL) {
-				couchdb_document_set_from_json_object (COUCHDB_DOCUMENT (document), obj);
+				couchdb_document_set_from_json_object (COUCHDB_DOCUMENT (document), doc);
 				doclist = g_slist_append (doclist, document);
 			}
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]