Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Cypher interpretation of commented lines ending in semicolons #64

Open
victoriastuart opened this issue Apr 6, 2018 · 0 comments
Open

Comments

@victoriastuart
Copy link

victoriastuart commented Apr 6, 2018

  • Neo4j version: 3.3.4
  • Operating system: Arch Linux x86_64 | XFCE
  • API/Driver: Cypher { cypher-shell: .../neo4j-community-3.3.4/bin/neo4j-shell | cycli 0.7.6}
  • Web browser: Firefox 59.0.2 (64-bit)
    • ditto: Chrome 65.0.3325.181 (Official Build) (64-bit) | Opera 52.0.2871.40
  • Neo4j Browser version: 3.1.4
  • Python versions: 3.6.4 (home env); 3.5.3 (venv)
    ** Cycli (pull File io py3 compatible #60 updated) is running in the Py3.5 venv

Hi: I'm not sure if this issue resides with Neo4j or Cycli; I suspect the latter (Cycli), as detailed below.

Problem Description

I prefer to use cypher scripts and Neovim, rather than the Neo4j Browser, for working with data.

However, when I comment-out ( // ... ) lines in the cypher scripts using a keyboard shortcut in Neovim, commented lines lines ending in semicolons throw warnings in Cycli.

The same code pasted into the Neo4j Browser, or the same script loaded into Neo4j via cypher-shell results in reading of the code, with no wrnings.

Thus, when I am writing scripts and and I want to comment out statements that end in a semicolon with my keyboard shortcut (Neovim editor), I ALSO need to go to the end of all of those //-commented lines and delete those semicolons (reversing that tedious process when uncommenting those lines).

That is, if I want to avoid seeing those warnings.

glycolysis_bioentities.csv
[exported form a PostgreSQL database, hence the .csv extension]:

name
α-D-glucose
glucose 6-phosphate
fructose 6-phosphate
"fructose 1,6-bisphosphate"
dihydroxyacetone phosphate
D-glyceraldehyde 3-phosphate
"1,3-bisphosphoglycerate"
3-phosphoglycerate
2-phosphoglycerate
phosphoenolpyruvate
pyruvate
hexokinase
glucose-6-phosphatase
phosphoglucose isomerase
phosphofructokinase
"fructose-bisphosphate aldolase, class I"
triosephosphate isomerase (TIM)
glyceraldehyde-3-phosphate dehydrogenase
phosphoglycerate kinase
phosphoglycerate mutase
enolase
pyruvate kinase

glycolysis.cypher:

LOAD CSV WITH HEADERS FROM "file:/glycolysis_bioentities.csv" AS row
MERGE (n:Glycolysis {name:row.name})
// RETURN n, labels(n), n.name;
RETURN n.name;
// Same:
// MATCH (n) RETURN n.name;

Examples - Cycli :

cycli -P 7474 -u victoria -p <password_obfuscated_here> -f glycolysis.cypher

> LOAD CSV WITH HEADERS FROM "/glycolysis_bioentities.csv" AS row
MERGE (n:Glycolysis {name:row.name})
// RETURN n, labels(n), n.name;
109 ms

> RETURN n.name;
Variable `n` not defined (line 1, column 8 (offset: 7))
"RETURN n.name;"
        ^

> // Same:
// MATCH (n) RETURN n.name;
Unexpected end of input: expected whitespace, comment, CYPHER options, EXPLAIN, PROFILE or Query (line 2, column 29 (offset: 37))
"// MATCH (n) RETURN n.name;"
                            ^

(py35) [victoria@victoria Vancouver]$ 

Despite those warnings, the 22 nodes are created in the Neo4j Browser. So it appears to be a warnings-related issue, not a script execution errors.

Compare that shell output to this modified script, where I deleted semicolons at ends of //-commented lines:

LOAD CSV WITH HEADERS FROM "file:/glycolysis_bioentities.csv" AS row
MERGE (n:Glycolysis {name:row.name})
// RETURN n, labels(n), n.name
RETURN n.name;
// Same
// MATCH (n) RETURN n.name

Script execution - Cycli :

cycli -P 7474 -u victoria -p <password_obfuscated_here> -f glycolysis.cypher

> LOAD CSV WITH HEADERS FROM "file:/glycolysis_bioentities.csv" AS row
MERGE (n:Glycolysis {name:row.name})
// RETURN n, labels(n), n.name
RETURN n.name;
n.name                                  
----------------------------------------
α-D-glucose                             
glucose 6-phosphate                     
fructose 6-phosphate                    
fructose 1,6-bisphosphate               
dihydroxyacetone phosphate              
D-glyceraldehyde 3-phosphate            
1,3-bisphosphoglycerate                 
3-phosphoglycerate                      
2-phosphoglycerate                      
phosphoenolpyruvate                     
pyruvate                                
hexokinase                              
glucose-6-phosphatase                   
phosphoglucose isomerase                
phosphofructokinase                     
fructose-bisphosphate aldolase, class I 
triosephosphate isomerase (TIM)         
glyceraldehyde-3-phosphate dehydrogenase
phosphoglycerate kinase                 
phosphoglycerate mutase                 
enolase                                 
pyruvate kinase                         

109 ms

Example - cypher-shell :

As mentioned, this does not occur when loading that same .cypher script into cypher-shell, where it runs without issue (resulting in 22 nodes in the Neo4j Browser):

cat glycolysis.cypher |  cypher-shell -u victoria -p <password_obfuscated_here>

n.name
"α-D-glucose"
"glucose 6-phosphate"
"fructose 6-phosphate"
"fructose 1,6-bisphosphate"
"dihydroxyacetone phosphate"
"D-glyceraldehyde 3-phosphate"
"1,3-bisphosphoglycerate"
"3-phosphoglycerate"
"2-phosphoglycerate"
"phosphoenolpyruvate"
"pyruvate"
"hexokinase"
"glucose-6-phosphatase"
"phosphoglucose isomerase"
"phosphofructokinase"
"fructose-bisphosphate aldolase, class I"
"triosephosphate isomerase (TIM)"
"glyceraldehyde-3-phosphate dehydrogenase"
"phosphoglycerate kinase"
"phosphoglycerate mutase"
"enolase"
"pyruvate kinase"

Thanks! :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant