php-rql icon indicating copy to clipboard operation
php-rql copied to clipboard

contains not working properly

Open Geekimo opened this issue 8 years ago • 3 comments

Hello, the contains function from the php-rql driver only supports one argument, but the JS driver supports multiples arguments.

Plus, the rAnd function should also support multiple arguments, like the JS one.

Is there any method to implement it ? How can I edit the rAnd implementation to make it support multiple arguments ?

Thanks.

Geekimo avatar Aug 27 '16 20:08 Geekimo

I noticed a comment in the source code saying that it will not be supported for the time being. Is there any technological issue ?

Geekimo avatar Aug 27 '16 22:08 Geekimo

Ok, problem solved, I updated the driver the following way by implementing the spec. ATM the solution is PHP7 only but I can support earliers versions of php.

rdb/ValuedQuery/ValuedQuery.php:243

    public function contains(...$values)
    {
        return new Contains($this, $values);
    }

rdb/Queries/Aggregations/Contains.php:10

    public function __construct(ValuedQuery $sequence, array $values)
    {
        $this->setPositionalArg(0, $sequence);

        foreach($values as $k => $value) {
            $this->setPositionalArg($k+1, $this->nativeToDatumOrFunction($value));
        }
    }

I don't know ATM how to push a PR, but as soon as I know, I'll do it.

I'm working on enhance rAnd and rOr too.

Geekimo avatar Aug 28 '16 08:08 Geekimo

Submitted PR #140 to solve issue

Geekimo avatar Aug 28 '16 17:08 Geekimo