Skip to content

'Branch' accepts only 2 + 1 arguments, not 2n +1 as expected. #142

Open
@martemorfosis

Description

@martemorfosis

I was trying to run this query which works perfectly on RethinkDB's Query Browser and JS Driver:

r.branch(
    r.expr(x).match('^avg'),
    r.expr(r.table('test')('statistics')(x).avg()),
    r.expr(x).match('lg'),
    r.expr(r.table('test')('statistics')(x).max()),
    r.expr(r.table('test')('statistics')(x).sum())
)

But in PHP when the first test was false I was getting the result of 'match'. The only workaround I found was to nest another 'branch' sentence in my PHP query:

r\branch(
r\expr($x)->match('^avg'),
r\expr(r\table('test')->getField('statistics')->getField($x)->avg()),
r\branch(
    r\expr($x)->match('lg'),
    r\expr(r\table('test')->getField('statistics')->getField($x)->max()),
    r\expr(r\table('test')->getField('statistics')->getField($x)->sum())
   )
)

In RethinkDB's docs and on PHP-RQL ones it is stated that 'Branch' works with 2n +1 arguments which is not the case on the current PHP implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions