You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Thomas Mohaupt <th...@gmail.com> on 2013/03/31 14:42:28 UTC

rewrites with keys and arrays

Hi,

I want to define a rewrite rule like:

{from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
[[1,':name'],[2,':name']]}},

But a request of

      /couch-dev/_design/app/_rewrite/foo/TA

is rewritten as

     /couch-dev/_design/app/_list/foo/bar?
reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA

which means var :name is not matched/resolved.

Any hints?

ThoMo

Re: rewrites with keys and arrays

Posted by Thomas Mohaupt <th...@gmail.com>.
ok, thanks.
At least I can stop looking my fault.

ThoMo


On Sun, Mar 31, 2013 at 3:45 PM, Benoit Chesneau <bc...@gmail.com>wrote:

> s/'/"
>
> but I just noticed you try to pass an array as key. This isn't
> supported by the rewriter yet.
>
> - benoit
>
> On Sun, Mar 31, 2013 at 3:18 PM, Thomas Mohaupt
> <th...@gmail.com> wrote:
> > Hm, doesn't change anything
> >
> > {from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
> > [[1,':name'],[2,':name']]}, formats: {name: 'string'}},
> >
> > results in
> >
> >
> /couch-dev/_design/app/_list/foo/bar?reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA
> >
> > (couchdb 1.2.1 on OSX)
> >
> > ThoMo
> >
> > On Sun, Mar 31, 2013 at 3:02 PM, Benoit Chesneau <bchesneau@gmail.com
> >wrote:
> >
> >> add
> >>
> >> "formats": {
> >>   "name": "string"
> >> }
> >>
> >> it should work.
> >>
> >> - benoît
> >>
> >> On Sun, Mar 31, 2013 at 2:42 PM, Thomas Mohaupt
> >> <th...@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > I want to define a rewrite rule like:
> >> >
> >> > {from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false',
> keys:
> >> > [[1,':name'],[2,':name']]}},
> >> >
> >> > But a request of
> >> >
> >> >       /couch-dev/_design/app/_rewrite/foo/TA
> >> >
> >> > is rewritten as
> >> >
> >> >      /couch-dev/_design/app/_list/foo/bar?
> >> >
> >>
> reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA
> >> >
> >> > which means var :name is not matched/resolved.
> >> >
> >> > Any hints?
> >> >
> >> > ThoMo
> >>
>

Re: rewrites with keys and arrays

Posted by Benoit Chesneau <bc...@gmail.com>.
s/'/"

but I just noticed you try to pass an array as key. This isn't
supported by the rewriter yet.

- benoit

On Sun, Mar 31, 2013 at 3:18 PM, Thomas Mohaupt
<th...@gmail.com> wrote:
> Hm, doesn't change anything
>
> {from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
> [[1,':name'],[2,':name']]}, formats: {name: 'string'}},
>
> results in
>
> /couch-dev/_design/app/_list/foo/bar?reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA
>
> (couchdb 1.2.1 on OSX)
>
> ThoMo
>
> On Sun, Mar 31, 2013 at 3:02 PM, Benoit Chesneau <bc...@gmail.com>wrote:
>
>> add
>>
>> "formats": {
>>   "name": "string"
>> }
>>
>> it should work.
>>
>> - benoît
>>
>> On Sun, Mar 31, 2013 at 2:42 PM, Thomas Mohaupt
>> <th...@gmail.com> wrote:
>> > Hi,
>> >
>> > I want to define a rewrite rule like:
>> >
>> > {from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
>> > [[1,':name'],[2,':name']]}},
>> >
>> > But a request of
>> >
>> >       /couch-dev/_design/app/_rewrite/foo/TA
>> >
>> > is rewritten as
>> >
>> >      /couch-dev/_design/app/_list/foo/bar?
>> >
>> reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA
>> >
>> > which means var :name is not matched/resolved.
>> >
>> > Any hints?
>> >
>> > ThoMo
>>

Re: rewrites with keys and arrays

Posted by Thomas Mohaupt <th...@gmail.com>.
Hm, doesn't change anything

{from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
[[1,':name'],[2,':name']]}, formats: {name: 'string'}},

results in

/couch-dev/_design/app/_list/foo/bar?reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA

(couchdb 1.2.1 on OSX)

ThoMo

On Sun, Mar 31, 2013 at 3:02 PM, Benoit Chesneau <bc...@gmail.com>wrote:

> add
>
> "formats": {
>   "name": "string"
> }
>
> it should work.
>
> - benoît
>
> On Sun, Mar 31, 2013 at 2:42 PM, Thomas Mohaupt
> <th...@gmail.com> wrote:
> > Hi,
> >
> > I want to define a rewrite rule like:
> >
> > {from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
> > [[1,':name'],[2,':name']]}},
> >
> > But a request of
> >
> >       /couch-dev/_design/app/_rewrite/foo/TA
> >
> > is rewritten as
> >
> >      /couch-dev/_design/app/_list/foo/bar?
> >
> reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA
> >
> > which means var :name is not matched/resolved.
> >
> > Any hints?
> >
> > ThoMo
>

Re: rewrites with keys and arrays

Posted by Benoit Chesneau <bc...@gmail.com>.
add

"formats": {
  "name": "string"
}

it should work.

- benoît

On Sun, Mar 31, 2013 at 2:42 PM, Thomas Mohaupt
<th...@gmail.com> wrote:
> Hi,
>
> I want to define a rewrite rule like:
>
> {from: '/foo/:name', to: '_list/foo/bar', query: {reduce: 'false', keys:
> [[1,':name'],[2,':name']]}},
>
> But a request of
>
>       /couch-dev/_design/app/_rewrite/foo/TA
>
> is rewritten as
>
>      /couch-dev/_design/app/_list/foo/bar?
> reduce=false&keys=%5B%5B1%2C%22%3Aname%22%5D%2C%5B2%2C%22%3Aname%22%5D%5D&name=TA
>
> which means var :name is not matched/resolved.
>
> Any hints?
>
> ThoMo