:param and :params parse numbers differently (Neo4j Browser 4.0.3, Neo4j 4.0)

Hey guys,

Just playing around with Parameters - Cypher Manual and there's an example where you use parameters with SKIP and LIMIT.

In Neo4j Browser 4.0.3, Neo4j 4.0 I do the following:
:params {s: 1, l: 1}

Which then stores 's' and 'l' as follows:

{
  "s": 1.0,
  "l": 1.0
}

Following along I try to follow along the docs with:

MATCH (n)
RETURN n
SKIP $s
LIMIT $l

And I get the error:

LIMIT: Invalid input. '2.0' is not a valid value. Must be a non-negative integer.

If I do:

:param s => 1
:param l => 1

Then the values get set to 1 vs 1.0 when passed in using :params ... seems a bit inconsistent?

{
"s": 1.0,
"l": 1.0
}
is javascript
To use paramaters in cypher use:
:param s => 1
:param l => 1

I don't understand your comment (in relation to the original post).

I was using :params to set the params. Are you saying that the argument to :params is JS? Even if that is so, the value 1 still got converted to 1.0.

If you see the link you shared it says {"s":1} is javascript command.
However if you use :param s=>1 in cypher then return $s will be 1 not 1.0

Yes, thanks for the explanation. I understand that, I guess the part I don't understand is what the :params command is doing. Maybe the answer is I shouldn't be using :params (I didn't actually see it in the docs, I just tried it and it worked lol), but if it's not supposed to be used, I'd question why it's there...

And it still doesn't answer the question about why :params converts 1 into 1.0 whereas :param does not do that conversion.

So I guess I still have questions around this, but can accept that the short answer might be to not use :params.

I guess you are mixing java/javascript code with cypher syntax
have a look @ Query parameters - Java Reference

cypher uses :param not :params

Could you share the code you wrote that turned 1 to 1.0?

I just wrote the following into Neo4j browser

That results in the two params being set:
$s which is 1.0
$l which is 1.0

If you type the following into Neo4j Browser you'll see what I mean:

:params {s: 1, l: 1}
RETURN $s, $l

Yes you are right.. there is inconsistency:

  1.  :param s: 1                    Return $s                1.0
    
  2.  :param s=>1                  Return $s                 1