bitnine-oss / agensgraph

AgensGraph, a transactional graph database based on PostgreSQL
http://www.agensgraph.org
Other
1.33k stars 148 forks source link

What query is similar to INSERT RETURNING ID in cypher? #539

Closed afidegnum closed 3 years ago

afidegnum commented 3 years ago

CREATE (s:snode {name: 'John', from: 'USA', age: 17}) RETURNING s; returns an error.

I'm automating an insertion, I want to be able to grab the last inserted id and pass it to the next iteration.

emotionbug commented 3 years ago

in cypher using RETURN statement. like CREATE ~ RETURN ~

afidegnum commented 3 years ago

I had the following error: CREATE (p:person {name: 'Daniel', from: 'Korea', age: 20}) RETURN p;

and this error: ``[FAIL] DataAccessException->StatementCallback; SQL [CREATE (p:person {name: 'Daniel', from: 'Korea', age: 20}) RETURN p;]; A result was returned when none was expected.; nested exception is org.postgresql.util.PSQLException: A result was returned when none was expected., SQL Code->0100E This is what I have gotten as an error

emotionbug commented 3 years ago

That error is occured in JDBC with your code.

https://github.com/pgjdbc/pgjdbc/blob/8be516d47ece60b7aeba5a9474b5cac1d538a04a/pgjdbc/src/main/java/org/postgresql/util/PSQLState.java#L43

Could you tell me how to reproduce it?

afidegnum commented 3 years ago

I only inserted a single query using via agensbrowser.

emotionbug commented 3 years ago

ROFL... I will look into it. How about use AGViewer or psql?

afidegnum commented 3 years ago

sorry I mean AGViewer, I tried with Psql and python and had a similar issue. Can you please also advise what step do i need to take in case I want to build a agensclient in Rust ??

emotionbug commented 3 years ago

i can't reproduce it your issue.

# psql -U postgres
psql (10.4)
Type "help" for help.

postgres=# create graph test;
CREATE GRAPH
postgres=# set graph_path='test';
SET
postgres=# CREATE (p:person {name: 'Daniel', from: 'Korea', age: 20}) RETURN p;
                             p
-----------------------------------------------------------
 person[3.1]{"age": 20, "from": "Korea", "name": "Daniel"}
(1 row)

https://github.com/sfackler/rust-postgres/issues/466 hmm... rust driver need to develop.

afidegnum commented 3 years ago

exactly the same query I did, I will give it a try again.

I'm highly motivated about rust development. since that's my main development language., I have come across lots of graph database but i'm more comfortable with this one since I can both use both RDMS and Graph query at the same time. I only pray for this product to sustain for a long period of time

joefagan commented 3 years ago

image Works for me as expected in agcloud.bitnine.net -> AGviewer

afidegnum commented 3 years ago

Thanks, I was having the problem rather on AgensBrowser. I couldn't run AGviewer, how did you run it? i followed the nodejs installation procedure

joefagan commented 3 years ago

Go agcloud.bitnine.net -> add a new project -> choose the first tutorial -> launch AGviewer You can then create your graph in the query editor of AGviewer. Skim through this tutorial https://www.youtube.com/watch?v=8S1IJswl7Lg&t=31s

emotionbug commented 3 years ago

@afidegnum instead, you can use docker.

docker run \
    --publish=3001:3001 \
    --name=agviewer \
    bitnine/agviewer:latest