CouchDatabase.execute_view should take an optional extra parameters dictionary

Bug #497143 reported by Stuart Langridge
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
desktopcouch
Fix Released
Low
Stuart Langridge

Bug Description

I understand that I can choose a particular key, or range of keys, for a view using index and slice notation. E.g.:

results = db.execute_view("my_view", "my_design_doc")
all_keys = list(results)
just_one_key = list(results["a key"])
keys_1_to_9 = list(results["key_1":"key_9"])

Am I correct in thinking that the above code runs 3 crouch queries with different settings for the key, startkey and endkey parameters?

What about other parameters? How do I ask for things like descending, group and group_level? Or am I using the wrong module if I want to do these things?

-------------------------

The way this should be done is to allow execute_view to take an extra parameters dict which is passed to self.db.view; this params dict can contain, for example, { "descending": True }

Related branches

Stuart Langridge (sil)
Changed in desktopcouch:
status: New → In Progress
assignee: nobody → Stuart Langridge (sil)
Stuart Langridge (sil)
Changed in desktopcouch:
importance: Undecided → Low
Revision history for this message
Niels Kjøller Hansen (kjoller) wrote :

Not to be unreasonable, but how is this a low priority issue? Being able to pass query options to a view seems relatively essential to me.

Revision history for this message
Niels Kjøller Hansen (kjoller) wrote :

I hereby retract my comment, as this has been fixed.

Revision history for this message
Niels Kjøller Hansen (kjoller) wrote :

Sorry to be spamming this bug, but it seems to me that the fixed branch still requires you to pass a dictionary as an option, as in

db.execute_view("view_name","design_doc",{ 'group':True })

If so, this does not seem very pythonic to me. I am not necessarily right, since I'm not that much of a hacker, but could it not be done by defining the function like this instead? :

def execute_view(self, view_name, design_doc=DEFAULT_DESIGN_DOCUMENT, **paramdict):

In my tests it works fine with 0, 1 or more paramters, and you don't even need to check if paramdict is empty, as it will automagically generate an empty dict.

Revision history for this message
Niels Kjøller Hansen (kjoller) wrote :

Okay, I have now made my proposed changes into a branch and linked it to this bug. I have never used launchpad to do this before, so please review with mistake-detection turned on.

To repeat this: It is certainly my opinion that this syntax (execute_view("aaa", "bbb", descending=True, group=True)) is way more elegant than passing a dictionary, but if there is any technical reason not to this, it should of course not be done.

JACQUELINE (ijdisabest)
Changed in desktopcouch:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.