You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "John Le Drew (JIRA)" <ji...@apache.org> on 2010/09/29 01:05:36 UTC

[jira] Created: (COUCHDB-899) Array fields being returned empty in permanent views, but work fine as temporary views.

Array fields being returned empty in permanent views, but work fine as temporary views.
---------------------------------------------------------------------------------------

                 Key: COUCHDB-899
                 URL: https://issues.apache.org/jira/browse/COUCHDB-899
             Project: CouchDB
          Issue Type: Bug
          Components: JavaScript View Server
    Affects Versions: 1.0.1
         Environment: CouchDB 1.0.1  running on Ubuntu 10.10 beta - this is the contents of my local.ini (comments removed)

[couchdb]
delayed_commits = false

[httpd]
port = 80
bind_address = 0.0.0.0

WWW-Authenticate = Basic realm="administrator"

[couch_httpd_auth]
require_valid_user = true

[log]
level = debug

            Reporter: John Le Drew


I am creating an accounting app; the transactions are stored using the following doc:

{
   "_id": "405b791b64424d12e03c12e6e5001535",
   "_rev": "1-97d53ba31a6ebb8c0508d0fc8776fac5",
   "type": "transaction",
   "account": "account_id",
   "payee": "Gas Company",
   "description": "May Bill",
   "date": "2009/05/25",
   "status": "cleared",
   "category": "Bills / Gas",
   "value": -5000
}

Or they can be split acroll multiple accounts / categories / etc. In this case split over two categories:

{
   "_id": "405b791b64424d12e03c12e6e5002532",
   "_rev": "1-da46384d5f9fbfd26acbf8fc9a8e82fe",
   "type": "transaction",
   "account": "account_id",
   "payee": "Credit Card Company",
   "description": "May Statement",
   "date": "2009/06/02",
   "status": "uncleared",
   "category": "Debt / Credit Card Payments",
   "value": -5000,
   "split": [
       {
           "category": "Dept / Default Charges",
           "value": -1000
       }
   ]
}

I have made a view to display all the unique categories in use across all transactions.

// MAP
function(doc) {
	if (doc.type && doc.type == 'transaction') {
		if (doc.category) emit(doc.category);
		if (doc.split) doc.split.map(function(spl) {
			if (spl.category) emit(spl.category);
		});
	}
}

// REDUCE
function(keys, values, rereduce) {
	return true;
}

// CURRENT OUTPUT OF VIEW (with group=true)
{
	"rows": [
		{
			"key": "Debt / Credit Card Payments", 
			"value": true
		}, 
		{
			"key": "Bills / Gas", 
			"value": true
		}
	]
}

// CURRENT OUTPUT OF VIEW WHEN RUN AS A TEMPORARY VIEW (with group=true)
{
	"rows": [
		{
			"key": "Dept / Default Charges", 
			"value": true
		}, 
		{
			"key": "Debt / Credit Card Payments", 
			"value": true
		}, 
		{
			"key": "Bills / Gas", 
			"value": true
		}
	]
}

SIMPLE TEST VIEW
function(doc) {
	if (doc.split) emit(null,doc.split);
}

OUTPUT OF TEMP VIEW
{
	"total_rows": 1, 
	"offset": 0, 
	"rows": [
		{
			"id": "405b791b64424d12e03c12e6e5002532", 
			"key": null, 
			"value": [
				{
					"category": "Dept / Default Charges", 
					"value": -1000
				}
			]
		}
	]
}

OUTPUT OF SAME VIEW AFTER SAVE
{
	"total_rows": 1, 
	"offset": 0, 
	"rows": [
		{
			"id": "405b791b64424d12e03c12e6e5002532", 
			"key": null, 
			"value": [
			]
		}
	]
}

It seems from the above that couch is for some reason returning the array as empty. 

Thanks for your time on IRC already.

Cheers

John

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (COUCHDB-899) Array fields being returned empty in permanent views, but work fine as temporary views.

Posted by "John Le Drew (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-899?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Le Drew updated COUCHDB-899:
---------------------------------


Same db replicated to my cloudant account does not show this issue.

> Array fields being returned empty in permanent views, but work fine as temporary views.
> ---------------------------------------------------------------------------------------
>
>                 Key: COUCHDB-899
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-899
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>         Environment: CouchDB 1.0.1  running on Ubuntu 10.10 beta - this is the contents of my local.ini (comments removed)
> [couchdb]
> delayed_commits = false
> [httpd]
> port = 80
> bind_address = 0.0.0.0
> WWW-Authenticate = Basic realm="administrator"
> [couch_httpd_auth]
> require_valid_user = true
> [log]
> level = debug
>            Reporter: John Le Drew
>
> I am creating an accounting app; the transactions are stored using the following doc:
> {
>    "_id": "405b791b64424d12e03c12e6e5001535",
>    "_rev": "1-97d53ba31a6ebb8c0508d0fc8776fac5",
>    "type": "transaction",
>    "account": "account_id",
>    "payee": "Gas Company",
>    "description": "May Bill",
>    "date": "2009/05/25",
>    "status": "cleared",
>    "category": "Bills / Gas",
>    "value": -5000
> }
> Or they can be split acroll multiple accounts / categories / etc. In this case split over two categories:
> {
>    "_id": "405b791b64424d12e03c12e6e5002532",
>    "_rev": "1-da46384d5f9fbfd26acbf8fc9a8e82fe",
>    "type": "transaction",
>    "account": "account_id",
>    "payee": "Credit Card Company",
>    "description": "May Statement",
>    "date": "2009/06/02",
>    "status": "uncleared",
>    "category": "Debt / Credit Card Payments",
>    "value": -5000,
>    "split": [
>        {
>            "category": "Dept / Default Charges",
>            "value": -1000
>        }
>    ]
> }
> I have made a view to display all the unique categories in use across all transactions.
> // MAP
> function(doc) {
> 	if (doc.type && doc.type == 'transaction') {
> 		if (doc.category) emit(doc.category);
> 		if (doc.split) doc.split.map(function(spl) {
> 			if (spl.category) emit(spl.category);
> 		});
> 	}
> }
> // REDUCE
> function(keys, values, rereduce) {
> 	return true;
> }
> // CURRENT OUTPUT OF VIEW (with group=true)
> {
> 	"rows": [
> 		{
> 			"key": "Debt / Credit Card Payments", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Bills / Gas", 
> 			"value": true
> 		}
> 	]
> }
> // CURRENT OUTPUT OF VIEW WHEN RUN AS A TEMPORARY VIEW (with group=true)
> {
> 	"rows": [
> 		{
> 			"key": "Dept / Default Charges", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Debt / Credit Card Payments", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Bills / Gas", 
> 			"value": true
> 		}
> 	]
> }
> SIMPLE TEST VIEW
> function(doc) {
> 	if (doc.split) emit(null,doc.split);
> }
> OUTPUT OF TEMP VIEW
> {
> 	"total_rows": 1, 
> 	"offset": 0, 
> 	"rows": [
> 		{
> 			"id": "405b791b64424d12e03c12e6e5002532", 
> 			"key": null, 
> 			"value": [
> 				{
> 					"category": "Dept / Default Charges", 
> 					"value": -1000
> 				}
> 			]
> 		}
> 	]
> }
> OUTPUT OF SAME VIEW AFTER SAVE
> {
> 	"total_rows": 1, 
> 	"offset": 0, 
> 	"rows": [
> 		{
> 			"id": "405b791b64424d12e03c12e6e5002532", 
> 			"key": null, 
> 			"value": [
> 			]
> 		}
> 	]
> }
> It seems from the above that couch is for some reason returning the array as empty. 
> Thanks for your time on IRC already.
> Cheers
> John

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-899) Array fields being returned empty in permanent views, but work fine as temporary views.

Posted by "John Le Drew (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12915964#action_12915964 ] 

John Le Drew commented on COUCHDB-899:
--------------------------------------

Also see pastie http://friendpaste.com/40Isk42SiEdxW4yi4DuPsm

> Array fields being returned empty in permanent views, but work fine as temporary views.
> ---------------------------------------------------------------------------------------
>
>                 Key: COUCHDB-899
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-899
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>         Environment: CouchDB 1.0.1  running on Ubuntu 10.10 beta - this is the contents of my local.ini (comments removed)
> [couchdb]
> delayed_commits = false
> [httpd]
> port = 80
> bind_address = 0.0.0.0
> WWW-Authenticate = Basic realm="administrator"
> [couch_httpd_auth]
> require_valid_user = true
> [log]
> level = debug
>            Reporter: John Le Drew
>
> I am creating an accounting app; the transactions are stored using the following doc:
> {
>    "_id": "405b791b64424d12e03c12e6e5001535",
>    "_rev": "1-97d53ba31a6ebb8c0508d0fc8776fac5",
>    "type": "transaction",
>    "account": "account_id",
>    "payee": "Gas Company",
>    "description": "May Bill",
>    "date": "2009/05/25",
>    "status": "cleared",
>    "category": "Bills / Gas",
>    "value": -5000
> }
> Or they can be split acroll multiple accounts / categories / etc. In this case split over two categories:
> {
>    "_id": "405b791b64424d12e03c12e6e5002532",
>    "_rev": "1-da46384d5f9fbfd26acbf8fc9a8e82fe",
>    "type": "transaction",
>    "account": "account_id",
>    "payee": "Credit Card Company",
>    "description": "May Statement",
>    "date": "2009/06/02",
>    "status": "uncleared",
>    "category": "Debt / Credit Card Payments",
>    "value": -5000,
>    "split": [
>        {
>            "category": "Dept / Default Charges",
>            "value": -1000
>        }
>    ]
> }
> I have made a view to display all the unique categories in use across all transactions.
> // MAP
> function(doc) {
> 	if (doc.type && doc.type == 'transaction') {
> 		if (doc.category) emit(doc.category);
> 		if (doc.split) doc.split.map(function(spl) {
> 			if (spl.category) emit(spl.category);
> 		});
> 	}
> }
> // REDUCE
> function(keys, values, rereduce) {
> 	return true;
> }
> // CURRENT OUTPUT OF VIEW (with group=true)
> {
> 	"rows": [
> 		{
> 			"key": "Debt / Credit Card Payments", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Bills / Gas", 
> 			"value": true
> 		}
> 	]
> }
> // CURRENT OUTPUT OF VIEW WHEN RUN AS A TEMPORARY VIEW (with group=true)
> {
> 	"rows": [
> 		{
> 			"key": "Dept / Default Charges", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Debt / Credit Card Payments", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Bills / Gas", 
> 			"value": true
> 		}
> 	]
> }
> SIMPLE TEST VIEW
> function(doc) {
> 	if (doc.split) emit(null,doc.split);
> }
> OUTPUT OF TEMP VIEW
> {
> 	"total_rows": 1, 
> 	"offset": 0, 
> 	"rows": [
> 		{
> 			"id": "405b791b64424d12e03c12e6e5002532", 
> 			"key": null, 
> 			"value": [
> 				{
> 					"category": "Dept / Default Charges", 
> 					"value": -1000
> 				}
> 			]
> 		}
> 	]
> }
> OUTPUT OF SAME VIEW AFTER SAVE
> {
> 	"total_rows": 1, 
> 	"offset": 0, 
> 	"rows": [
> 		{
> 			"id": "405b791b64424d12e03c12e6e5002532", 
> 			"key": null, 
> 			"value": [
> 			]
> 		}
> 	]
> }
> It seems from the above that couch is for some reason returning the array as empty. 
> Thanks for your time on IRC already.
> Cheers
> John

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (COUCHDB-899) Array fields being returned empty in permanent views, but work fine as temporary views.

Posted by "Paul Joseph Davis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-899?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Joseph Davis resolved COUCHDB-899.
---------------------------------------

    Resolution: Invalid

Underlying clause was that the doc was being edited in a different map view.

We should re-investigate document sealing to prevent this.

> Array fields being returned empty in permanent views, but work fine as temporary views.
> ---------------------------------------------------------------------------------------
>
>                 Key: COUCHDB-899
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-899
>             Project: CouchDB
>          Issue Type: Bug
>          Components: JavaScript View Server
>    Affects Versions: 1.0.1
>         Environment: CouchDB 1.0.1  running on Ubuntu 10.10 beta - this is the contents of my local.ini (comments removed)
> [couchdb]
> delayed_commits = false
> [httpd]
> port = 80
> bind_address = 0.0.0.0
> WWW-Authenticate = Basic realm="administrator"
> [couch_httpd_auth]
> require_valid_user = true
> [log]
> level = debug
>            Reporter: John Le Drew
>
> I am creating an accounting app; the transactions are stored using the following doc:
> {
>    "_id": "405b791b64424d12e03c12e6e5001535",
>    "_rev": "1-97d53ba31a6ebb8c0508d0fc8776fac5",
>    "type": "transaction",
>    "account": "account_id",
>    "payee": "Gas Company",
>    "description": "May Bill",
>    "date": "2009/05/25",
>    "status": "cleared",
>    "category": "Bills / Gas",
>    "value": -5000
> }
> Or they can be split acroll multiple accounts / categories / etc. In this case split over two categories:
> {
>    "_id": "405b791b64424d12e03c12e6e5002532",
>    "_rev": "1-da46384d5f9fbfd26acbf8fc9a8e82fe",
>    "type": "transaction",
>    "account": "account_id",
>    "payee": "Credit Card Company",
>    "description": "May Statement",
>    "date": "2009/06/02",
>    "status": "uncleared",
>    "category": "Debt / Credit Card Payments",
>    "value": -5000,
>    "split": [
>        {
>            "category": "Dept / Default Charges",
>            "value": -1000
>        }
>    ]
> }
> I have made a view to display all the unique categories in use across all transactions.
> // MAP
> function(doc) {
> 	if (doc.type && doc.type == 'transaction') {
> 		if (doc.category) emit(doc.category);
> 		if (doc.split) doc.split.map(function(spl) {
> 			if (spl.category) emit(spl.category);
> 		});
> 	}
> }
> // REDUCE
> function(keys, values, rereduce) {
> 	return true;
> }
> // CURRENT OUTPUT OF VIEW (with group=true)
> {
> 	"rows": [
> 		{
> 			"key": "Debt / Credit Card Payments", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Bills / Gas", 
> 			"value": true
> 		}
> 	]
> }
> // CURRENT OUTPUT OF VIEW WHEN RUN AS A TEMPORARY VIEW (with group=true)
> {
> 	"rows": [
> 		{
> 			"key": "Dept / Default Charges", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Debt / Credit Card Payments", 
> 			"value": true
> 		}, 
> 		{
> 			"key": "Bills / Gas", 
> 			"value": true
> 		}
> 	]
> }
> SIMPLE TEST VIEW
> function(doc) {
> 	if (doc.split) emit(null,doc.split);
> }
> OUTPUT OF TEMP VIEW
> {
> 	"total_rows": 1, 
> 	"offset": 0, 
> 	"rows": [
> 		{
> 			"id": "405b791b64424d12e03c12e6e5002532", 
> 			"key": null, 
> 			"value": [
> 				{
> 					"category": "Dept / Default Charges", 
> 					"value": -1000
> 				}
> 			]
> 		}
> 	]
> }
> OUTPUT OF SAME VIEW AFTER SAVE
> {
> 	"total_rows": 1, 
> 	"offset": 0, 
> 	"rows": [
> 		{
> 			"id": "405b791b64424d12e03c12e6e5002532", 
> 			"key": null, 
> 			"value": [
> 			]
> 		}
> 	]
> }
> It seems from the above that couch is for some reason returning the array as empty. 
> Thanks for your time on IRC already.
> Cheers
> John

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.