TropicalPenguin opened a new issue, #339:
URL: https://github.com/apache/age/issues/339
**Describe the bug**
Given the basic data set up:
`CREATE (:A)-[:incs]->(:C)`
The following succeeds:
`MATCH (a:A) WITH a OPTIONAL MATCH (a)-[:incs]->(c) WHERE
EXISTS((c)<-[:incs]-()) RETURN a,c`
But simply adding an alias for the source vertex makes the query fail:
`MATCH (a:A) WITH a OPTIONAL MATCH (a)-[:incs]->(c) WHERE
EXISTS((c)<-[:incs]-(a)) RETURN a,c`
With the following error:
`pq: attribute 1 of type test.incs has wrong type`
I have confirmed that both matches succeed with identical output in Neo4j
sandbox.
**How are you accessing AGE (Command line, driver, etc.)?**
- Command line
- Golang driver
**What data setup do we need to do?**
Either run the above commands in psql, or try the following short test
golang program:
```go
package main
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
"github.com/rhizome-ai/apache-age-go/age"
)
func main() {
dsn :=
"postgres://postgres:[email protected]:5434/postgres?sslmode=disable"
db, err := sql.Open("postgres", dsn)
if err != nil {
panic(err)
}
graphName := "test"
_, err = age.GetReady(db, graphName)
if err != nil {
panic(err)
}
tx, err := db.Begin()
if err != nil {
panic(err)
}
var row []age.Entity
cursor, err := age.ExecCypher(tx, graphName, 0, "CREATE
(:A)-[:incs]->(:C)")
if err != nil {
panic(err)
}
cursor, err = age.ExecCypher(tx, graphName, 2, "MATCH (a:A) WITH a
OPTIONAL MATCH (a)-[:incs]->(c) WHERE EXISTS((c)<-[:incs]-()) RETURN a,c")
if err != nil {
panic(err)
}
for cursor.Next() {
row, err = cursor.GetRow()
for rowIdx, v := range row {
fmt.Println(rowIdx, len(row), v)
}
}
fmt.Printf("\n")
cursor, err = age.ExecCypher(tx, graphName, 2, "MATCH (a:A) WITH a
OPTIONAL MATCH (a)-[:incs]->(c) WHERE EXISTS((c)<-[:incs]-(a)) RETURN a,c")
if err != nil {
panic(err)
}
for cursor.Next() {
row, err = cursor.GetRow()
for rowIdx, v := range row {
fmt.Println(rowIdx, len(row), v)
}
}
_, err = tx.Exec(fmt.Sprintf("SELECT drop_graph('%s', true);",
graphName))
if err != nil {
panic(err)
}
tx.Commit()
}
```
**What is the necessary configuration info needed?**
- N/A
**What is the command that caused the error?**
```pgsql
SELECT * from cypher('test', $$
MATCH (a:A) WITH a OPTIONAL MATCH (a)-[:incs]->(c) WHERE
EXISTS((c)<-[:incs]-(a)) RETURN a,c
$$) as (a agtype, c agtype);
```
```
ERROR: attribute 1 of type test.incs has wrong type
```
**Expected behavior**
The two queries should return the same result, without error.
**Environment (please complete the following information):**
- Version: 1.0.0
**Additional context**
N/A
--
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]