@@ -57,6 +57,11 @@ function consoleOut(text) {
57
57
loggerLog ( text , VERBOSE ) ;
58
58
}
59
59
60
+ function sanitize ( text ) {
61
+ // TODO implement sanitization logic
62
+ return text ;
63
+ }
64
+
60
65
/**
61
66
* Executes a neptune query
62
67
* @param query the query to execute
@@ -158,8 +163,7 @@ async function getEdgesNames() {
158
163
159
164
160
165
async function findFromAndToLabels ( edgeStructure ) {
161
- let query = `MATCH (from)-[r]->(to) WHERE type(r) = $edge RETURN DISTINCT labels(from) as fromLabel, labels(to) as toLabel` ;
162
- let parameters = `{"edge": "${ edgeStructure . label } "}` ;
166
+ let query = `MATCH (from)-[r:${ sanitize ( edgeStructure . label ) } ]->(to) RETURN DISTINCT labels(from) as fromLabel, labels(to) as toLabel` ;
163
167
let response = await queryNeptune ( query , parameters ) ;
164
168
for ( let result of response . results ) {
165
169
for ( let fromLabel of result . fromLabel ) {
@@ -216,9 +220,8 @@ function addUpdateEdgeProperty(edgeName, name, value) {
216
220
217
221
218
222
async function getEdgeProperties ( edge ) {
219
- let query = `MATCH ()-[n]->() WHERE type(n) = $label RETURN properties(n) as properties LIMIT $sample` ;
220
- let parameters = `{"label": "${ edge . label } ", "sample": ${ SAMPLE } }` ;
221
- loggerLog ( `Getting properties for edge: ${ query } ` ) ;
223
+ let query = `MATCH ()-[n:${ sanitize ( edge . label ) } ]->() RETURN properties(n) as properties LIMIT $sample` ;
224
+ let parameters = `{"sample": ${ SAMPLE } }` ;
222
225
try {
223
226
let response = await queryNeptune ( query , parameters ) ;
224
227
let result = response . results ;
@@ -244,8 +247,8 @@ async function getEdgesProperties() {
244
247
245
248
246
249
async function getNodeProperties ( node ) {
247
- let query = `MATCH (n) WHERE $label in labels(n ) RETURN properties(n) as properties LIMIT $sample` ;
248
- let parameters = `{"label": " ${ node . label } ", " sample": ${ SAMPLE } }` ;
250
+ let query = `MATCH (n: ${ sanitize ( node . label ) } ) RETURN properties(n) as properties LIMIT $sample` ;
251
+ let parameters = `{"sample": ${ SAMPLE } }` ;
249
252
try {
250
253
let response = await queryNeptune ( query , parameters ) ;
251
254
let result = response . results ;
@@ -271,25 +274,10 @@ async function getNodesProperties() {
271
274
272
275
273
276
async function checkEdgeDirectionCardinality ( d ) {
274
- let parameters = `{"from": "${ d . from } ", "edge": "${ d . edge . label } ", "to": "${ d . to } "}` ;
275
- let queryFrom = `MATCH(from)-[r]->(to)
276
- WHERE $from in labels(from)
277
- AND type(r) = $edge
278
- AND $to in labels(to)
279
- WITH to, count(from) as rels
280
- WHERE rels > 1
281
- RETURN rels LIMIT 1` ;
282
- loggerLog ( `Checking edge direction cardinality: ${ queryFrom } ` ) ;
277
+ let queryFrom = `MATCH (from:${ sanitize ( d . from ) } )-[r:${ sanitize ( d . edge . label ) } ]->(to:${ sanitize ( d . to ) } ) WITH to, count(from) as rels WHERE rels > 1 RETURN rels LIMIT 1` ;
283
278
let responseFrom = await queryNeptune ( queryFrom , parameters ) ;
284
279
let resultFrom = responseFrom . results [ 0 ] ;
285
- let queryTo = `MATCH(from)-[r]->(to)
286
- WHERE $from in labels(from)
287
- AND type(r) = $edge
288
- AND $to in labels(to)
289
- WITH from, count(to) as rels
290
- WHERE rels > 1
291
- RETURN rels LIMIT 1` ;
292
- loggerLog ( `Checking edge direction cardinality: ${ queryTo } ` ) ;
280
+ let queryTo = `MATCH (from:${ sanitize ( d . from ) } )-[r:${ sanitize ( d . edge . label ) } ]->(to:${ sanitize ( d . to ) } ) WITH from, count(to) as rels WHERE rels > 1 RETURN rels LIMIT 1` ;
293
281
let responseTo = await queryNeptune ( queryTo , parameters ) ;
294
282
let resultTo = responseTo . results [ 0 ] ;
295
283
let c = '' ;
0 commit comments