Comments (6)
The format $1
is the Postgres format for parameters and cannot be used in the cypher query. Parameters in the cypher query must take the format $parameter_name
. When you want to pass parameters to a cypher query, you must add a third argument to the cypher query. This argument must be a Postgres parameter. So your query must look like:
SELECT * FROM cypher('testgraph', $$CREATE (v:Person {name: $var_name})$$, $1) as (a agtype);
When executing the query the value passed to $1
must be an agtype map, where the key is the variable name. NOTE: All parameters in the cypher query are passed in the map.
Also, both AGE parameters and Postgres parameters can only be used in prepared statements. So the above query will not currently work as it is related to the github issues: #39 & #28. We are currently working on a fix for these issues.
from age.
Some general questions/troubleshooting thoughts:
- Is that error coming from your
SET
command or theSELECT * from cypher
query? - Does the code work if you hardcode a name instead of
$1
? - If not, maybe a library parsing issue? Try spaces after/before the $$ : `$$ CREATE (v:Person {name:
$1}) $ $ )``
from age.
- The error originates from the
SELECT * from cypher
query. - In both cases, the hardcoded query
SELECT * FROM cypher('testgraph', $$CREATE (v:Person {name: 'Tom'})$$) as (a agtype);
does work. - Spaces after/before the $$ don't change the outcome.
Both asyncpg and node-postgres appear to rely on libpq.
from age.
I am able to reproduce the error, and have a little more detail below regarding where the error occurs in AGE (ag_scanner.l).
error: unexpected character at or near "$"
at Parser.parseErrorMessage (/home/nicho/bitnine/testjs/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/home/nicho/bitnine/testjs/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/home/nicho/bitnine/testjs/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/home/nicho/bitnine/testjs/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (node:events:378:20)
at addChunk (node:internal/streams/readable:313:12)
at readableAddChunk (node:internal/streams/readable:288:9)
at Socket.Readable.push (node:internal/streams/readable:227:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 109,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '75',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'ag_scanner.l',
line: '711',
routine: 'ag_scanner_next_token'
from age.
@pdpotter The python and NodeJs drivers are now compatible with the CREATE, SET, REMOVE and DELETE clauses. Btw, I never had the opportunity to play around with this particular python driver. Seems like a very interesting library.
from age.
It is now indeed possible to use prepared statements to create nodes. Thank you!
from age.
Related Issues (20)
- Please work around limitation of 100 or 50 fields for the function parameters such as agtype_build_map and internally invoked CREATE HOT 11
- Server crashes when executing SELECT * FROM cypher('list_comprehension' ...) HOT 5
- OLTP vs OLAP Graph Querying HOT 7
- Compatibility Query: Running Cloned Apache Age Code on Windows OS? HOT 2
- Flaky test age_global_graph fails on slow machines HOT 4
- unable to pull the docker image with 'latest' tag HOT 8
- Ambiguous column reference error when returning variable used in the RHS of SET clause
- Flaky test cypher_delete fails on slow machines
- GQL Support HOT 2
- Can we improve query performance?
- SET on MERGE not storing edge properties inside the database on creation HOT 8
- Server crashes when using exists(path) with explicit lenght paths HOT 7
- Since there seems to be special requirements for label name, it would be nice to extend a function to verify name correctness HOT 3
- Which quality Postgres hosts allow the AGE extension? HOT 1
- Is there any restriction to support for psycopg2-binary in python driver?
- Performance issues with edge creation for larger dataset with 83K edges HOT 4
- How to extract values of a nested JSON and use in MATCH query, also can we index based on the properties of nested json?
- Replace function "" is needed while using hybrid queries
- How to assign cypher result to pgsql variable? HOT 2
- Is data duplicated in parent and label/edge tables? What are the internals? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from age.