WendelLana opened a new issue, #894:
URL: https://github.com/apache/age/issues/894

   **Describe the bug**
   I'm creating a function in PostgreSQL, but I believe that the parameter 
`search_name` of the `text` type is not accessible within the Cypher query.
   
   **How are you accessing AGE (Command line, driver, etc.)?**
   - Command line
   
   **What data setup do we need to do?**
   ```pgsql
   SELECT * from cypher('graph_name', $$
     CREATE (a:Person {name: 'A'}), 
            (b:Person {name: 'B'}), 
            (c:Person {name: 'C'}), 
            (d:Person {name: 'D'})
   $$) as (a agtype);
   SELECT * FROM cypher('graph_name', $$
       MATCH (a:Person), (b:Person)
       WHERE a.name = 'A' AND b.name <> 'A'
       CREATE (a)-[e:friends_with]->(b)
       RETURN e
   $$) AS (e agtype);
   ```
   
   **What is the necessary configuration info needed?**
   - none
   
   **What is the command that caused the error?**
   ```plpgsql
   CREATE OR REPLACE FUNCTION count_friends(search_name text)
       RETURNS integer AS $function$
       BEGIN
           RETURN (
               SELECT COUNT(*) FROM cypher('graph_name', $$
                   MATCH (v:Person)-[]-(w)
                   WHERE v.name = search_name
                   RETURN w AS friend
               $$) AS (friends agtype)
           );
       END;
   $function$ LANGUAGE plpgsql;
   ```
   To test the function, I ran this simple query:
   ```
   SELECT count_friends('A');
   ```
   And I got this error:
   ```
   ERROR:  could not find rte for name
   ```
   
   **Expected behavior**
   The function should return the number of friends that a specified person, 
identified by their name, has.
   
   **Environment (please complete the following information):**
   - Version: Apache AGE release 1.3.0 in PostgreSQL 13.10
   
   **Additional commentaries**
   I'm not sure if this is a new feature, similar to query parameters in Neo4j, 
or simply an error in the categorization of an expression within the function 
`transform_cypher_expr_recurse`. Alternatively, it could be related to another 
issue in the `transform_ColumnRef` function.


-- 
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]

Reply via email to