Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martemorfosis opened this issue Sep 21, 2016 · 1 comment
Open

Comments

@martemorfosis
Copy link

martemorfosis commented Sep 21, 2016

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.

@Geekimo
Copy link

Geekimo commented Sep 30, 2016

I will take a look at it asap. I had the same issue with other methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants