jrgemignani commented on issue #315:
URL: https://github.com/apache/age/issues/315#issuecomment-1331204312
I think there is confusion, likely on both sides, of what a parameter is and
how it is used.
The cypher function can take **PG parameters** as the 3rd argument, like you
gave. However, a **PG parameter** isn't the same as a constant value, passed as
a variable, which is what you are using.
Note the error messages -
```
psql-11.5-5432-pgsql=# SELECT * from cypher('test_graph',$$ MATCH (u:User
{user_id: $user_id})
RETURN u.user_id $$, '{"user_id":"test_user"}') AS (a agtype);
ERROR: third argument of cypher function must be a parameter
LINE 2: RETURN u.user_id $$, '{"user_id":"test_user"}') AS (a agtype...
^
psql-11.5-5432-pgsql=# SELECT * from cypher('test_graph',$$ MATCH (u:User
{user_id: $user_id})
RETURN u.user_id $$, $1) AS (a agtype);
ERROR: there is no parameter $1
LINE 2: RETURN u.user_id $$, $1) AS (a agtype);
```
But, it looks like what you are asking is more like the following, which
doesn't work either.
```
psql-11.5-5432-pgsql=# \set user_id '{"user_id":"test_user"}'
psql-11.5-5432-pgsql=# SELECT * from cypher('test_graph',$$ MATCH (u:User
{user_id: $user_id})
RETURN u.user_id $$, :user_id) AS (a agtype);
ERROR: syntax error at or near "{"
LINE 2: RETURN u.user_id $$, {"user_id":"test_user"}) AS (a agtype);
psql-11.5-5432-pgsql=# \set user_id '''{"user_id":"test_user"}'''
psql-11.5-5432-pgsql=# SELECT * from cypher('test_graph',$$ MATCH (u:User
{user_id: $user_id})
RETURN u.user_id $$, :user_id) AS (a agtype);
ERROR: third argument of cypher function must be a parameter
LINE 2: RETURN u.user_id $$, '{"user_id":"test_user"}') AS (a agtype...
^
```
It should be possible, and relatively straightforward, to allow the 3rd
value to take on a constant value. However, I'm not sure how useful adding that
would be for users.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]