[couchdb-glib] Fix retrieval of documents
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [couchdb-glib] Fix retrieval of documents
- Date: Fri, 24 Dec 2010 12:52:50 +0000 (UTC)
commit b705bdd9b80ed3acb7e38c2ed9e7b45258d50803
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Thu Dec 23 14:48:04 2010 +0100
Fix retrieval of documents
couchdb-glib/couchdb-database.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/couchdb-glib/couchdb-database.c b/couchdb-glib/couchdb-database.c
index 81a12ed..b41c56f 100644
--- a/couchdb-glib/couchdb-database.c
+++ b/couchdb-glib/couchdb-database.c
@@ -180,13 +180,12 @@ couchdb_database_init (CouchdbDatabase *database)
static CouchdbDocument *
create_document_from_json_object (JsonObject *json_object)
{
- CouchdbDocument *document;
+ CouchdbDocument *document = NULL;
- if (g_str_has_prefix (json_object_get_string_member (json_object, "id"),
- "_design/")) {
+ if (json_object_has_member (json_object, "_id") &&
+ g_str_has_prefix (json_object_get_string_member (json_object, "_id"), "_design/")) {
document = COUCHDB_DOCUMENT (couchdb_design_document_new ());
- couchdb_document_set_from_json_object (document,
- json_object_get_object_member (json_object, "doc"));
+ couchdb_document_set_from_json_object (document, json_object);
} else {
if (json_object_has_member (json_object, "record_type")) {
if (g_strcmp0 (json_object_get_string_member (json_object, "record_type"),
@@ -401,10 +400,12 @@ couchdb_database_get_all_documents (CouchdbDatabase *database, GError **error)
if (!obj)
continue;
- document = create_document_from_json_object (json_object_get_object_member (obj, "doc"));
- if (document != NULL) {
- g_object_set (G_OBJECT (document), "database", database, NULL);
- doclist = g_slist_append (doclist, document);
+ if (json_object_has_member (obj, "doc")) {
+ document = create_document_from_json_object (json_object_get_object_member (obj, "doc"));
+ if (document != NULL) {
+ g_object_set (G_OBJECT (document), "database", database, NULL);
+ doclist = g_slist_append (doclist, document);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]