dready92 / PHP-on-Couch

Data Access Library to access a CouchDB server with PHP.

Home Page:http://dready.byethost31.com/index.php/display/view/192

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot unset staticValue view query parameters

MrTrick opened this issue · comments

Once set, there is no way to unset view parameters of type 'staticValue'.
I suggest that the __call function check the 'truthiness' of the argument, and set/clear that parameter accordingly.

                } elseif ( $this->query_defs[$name]['filter'] == 'staticValue' ) {
-                       $this->query_parameters[ $this->query_defs[$name]['name'] ] = $this->query_defs[$name]['staticValue'];
+                   if (reset($args)) $this->query_parameters[ $this->query_defs[$name]['name'] ] = $this->query_defs[$name]['staticValue'];
+                   else unset($this->query_parameters[ $this->query_defs[$name]['name'] ]);
                } elseif ( $this->query_defs[$name]['filter'] == 'jsonEncode' ) {

While it seems pretty logical to me, it does have the potential to break existing code: eg a programmer writing "$client->stale=false;" and expecting "stale=ok"

Can we actually unset other types of parameters ? I doubt so. In fact I did it on purpose, I don't see the point of coding "I create a query, set a parameter, ah finally no I unset it..." What's your opinion on this ?

Without further discussion, I'm closing this issue for now. Feel free to reopen it.