From 37daf814d8d5cbded34a0fb2b42419e75a404307 Mon Sep 17 00:00:00 2001 From: Giuseppe Villani Date: Thu, 18 Feb 2021 09:18:00 +0100 Subject: [PATCH] fixes #1612: Neo4j 4 on Aura permissions adjustment due to PUBLIC role --- core/src/main/java/apoc/cypher/Cypher.java | 13 ++++++ .../src/test/java/apoc/cypher/CypherTest.java | 36 ++++++++++++++++- .../apoc.cypher-lite.csv | 2 + .../generated-documentation/apoc.cypher.csv | 2 + .../apoc.cypher.runSchema-lite.csv | 2 + .../apoc.cypher.runSchema.adoc | 5 +++ .../apoc.cypher.runWrite-lite.csv | 2 + .../apoc.cypher.runWrite.adoc | 5 +++ .../generated-documentation/documentation.csv | 2 + .../apoc.cypher/apoc.cypher.runSchema.adoc | 40 +++++++++++++++++++ .../apoc.cypher/apoc.cypher.runWrite.adoc | 36 +++++++++++++++++ .../pages/overview/apoc.cypher/index.adoc | 10 +++++ .../documentation.adoc | 10 +++++ .../partials/generated-documentation/nav.adoc | 2 + .../ROOT/partials/usage/apoc.cypher.doIt.adoc | 2 + .../partials/usage/apoc.cypher.runSchema.adoc | 11 +++++ 16 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema-lite.csv create mode 100644 docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema.adoc create mode 100644 docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite-lite.csv create mode 100644 docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite.adoc create mode 100644 docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runSchema.adoc create mode 100644 docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runWrite.adoc create mode 100644 docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.runSchema.adoc diff --git a/core/src/main/java/apoc/cypher/Cypher.java b/core/src/main/java/apoc/cypher/Cypher.java index 2739b00144..a436d838ea 100644 --- a/core/src/main/java/apoc/cypher/Cypher.java +++ b/core/src/main/java/apoc/cypher/Cypher.java @@ -43,6 +43,7 @@ import static java.lang.String.format; import static java.lang.String.join; import static java.util.stream.Collectors.toList; +import static org.neo4j.procedure.Mode.SCHEMA; import static org.neo4j.procedure.Mode.WRITE; /** @@ -242,6 +243,18 @@ public Stream doIt(@Name("cypher") String statement, @Name("params") return runCypherQuery(tx, statement, params); } + @Procedure(mode = WRITE) + @Description("apoc.cypher.runWrite(fragment, params) yield value - alias for apoc.cypher.doIt") + public Stream runWrite(@Name("cypher") String statement, @Name("params") Map params) { + return doIt(statement, params); + } + + @Procedure(mode = SCHEMA) + @Description("apoc.cypher.runSchema(fragment, params) yield value - executes query schema fragment with the given parameters") + public Stream runSchema(@Name("cypher") String statement, @Name("params") Map params) { + return runCypherQuery(tx, statement, params); + } + @Procedure("apoc.when") @Description("apoc.when(condition, ifQuery, elseQuery:'', params:{}) yield value - based on the conditional, executes read-only ifQuery or elseQuery with the given parameters") public Stream when(@Name("condition") boolean condition, @Name("ifQuery") String ifQuery, @Name(value="elseQuery", defaultValue = "") String elseQuery, @Name(value="params", defaultValue = "{}") Map params) { diff --git a/core/src/test/java/apoc/cypher/CypherTest.java b/core/src/test/java/apoc/cypher/CypherTest.java index 20e3fa4dc4..2aa927bec2 100644 --- a/core/src/test/java/apoc/cypher/CypherTest.java +++ b/core/src/test/java/apoc/cypher/CypherTest.java @@ -14,10 +14,12 @@ import org.junit.rules.ExpectedException; import org.neo4j.configuration.GraphDatabaseSettings; import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.QueryExecutionException; import org.neo4j.graphdb.Result; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.schema.ConstraintDefinition; import org.neo4j.graphdb.schema.IndexDefinition; +import org.neo4j.internal.helpers.collection.Iterables; import org.neo4j.internal.helpers.collection.Iterators; import org.neo4j.test.rule.DbmsRule; import org.neo4j.test.rule.ImpermanentDbmsRule; @@ -32,6 +34,8 @@ import static apoc.ApocConfig.APOC_IMPORT_FILE_ENABLED; import static apoc.ApocConfig.apocConfig; import static apoc.util.TestUtil.testCall; +import static apoc.util.TestUtil.testCallEmpty; +import static apoc.util.TestUtil.testFail; import static apoc.util.TestUtil.testResult; import static apoc.util.Util.map; import static java.util.Collections.emptyMap; @@ -39,6 +43,7 @@ import static org.hamcrest.Matchers.hasEntry; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -66,12 +71,41 @@ public static void setUp() { public void clearDB() { db.executeTransactionally("MATCH (n) DETACH DELETE n"); try (Transaction tx = db.beginTx()) { - tx.schema().getIndexes().forEach(IndexDefinition::drop); tx.schema().getConstraints().forEach(ConstraintDefinition::drop); + tx.schema().getIndexes().forEach(IndexDefinition::drop); tx.commit(); } } + @Test + public void testDoIt() throws Exception { + + testCallEmpty(db, "CALL apoc.cypher.doIt('CREATE (n:TestOne {a: $b})',{b: 32})", emptyMap()); + + testCall(db, "CALL apoc.cypher.doIt('Match (n:TestOne) return n',{})", + r -> assertEquals("TestOne", Iterables.single(((Node)((Map) r.get("value")).get("n")).getLabels()).name())); + + testFail(db, "CALL apoc.cypher.doIt('CREATE INDEX test FOR (w:TestOne) ON (w.foo)',{})", QueryExecutionException.class); + + testCallEmpty(db, "CALL apoc.cypher.runWrite('CREATE (n:TestTwo {a: $b})',{b: 32})", emptyMap()); + + testCall(db, "CALL apoc.cypher.runWrite('Match (n:TestTwo) return n',{})", + r -> assertEquals("TestTwo", Iterables.single(((Node)((Map) r.get("value")).get("n")).getLabels()).name())); + + testFail(db, "CALL apoc.cypher.runWrite('CREATE INDEX test FOR (w:TestTwo) ON (w.foo)',{})", QueryExecutionException.class); + } + + @Test + public void testRunSchema() throws Exception { + testCallEmpty(db, "CALL apoc.cypher.runSchema('CREATE INDEX test FOR (w:TestOne) ON (w.name)',{})", Collections.emptyMap()); + testCallEmpty(db, "CALL apoc.cypher.runSchema('CREATE CONSTRAINT testConstraint ON (w:TestTwo) ASSERT w.baz IS UNIQUE',{})", Collections.emptyMap()); + + try (Transaction tx = db.beginTx()) { + assertNotNull(tx.schema().getConstraintByName("testConstraint")); + assertNotNull(tx.schema().getIndexByName("test")); + } + } + @Test public void testRun() throws Exception { testCall(db, "CALL apoc.cypher.run('RETURN $a + 7 as b',{a:3})", diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher-lite.csv b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher-lite.csv index 5fe688d258..a563de30af 100644 --- a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher-lite.csv +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher-lite.csv @@ -8,9 +8,11 @@ ¦apoc.cypher.runFile(file :: STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?) ¦apoc.cypher.runFiles(file :: LIST? OF STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?) ¦apoc.cypher.runMany(cypher :: STRING?, params :: MAP?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?) +¦apoc.cypher.runSchema(cypher :: STRING?, params :: MAP?) :: (value :: MAP?) ¦apoc.cypher.runSchemaFile(file :: STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?) ¦apoc.cypher.runSchemaFiles(file :: LIST? OF STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?) ¦apoc.cypher.runTimeboxed(cypher :: STRING?, params :: MAP?, timeout :: INTEGER?) :: (value :: MAP?) +¦apoc.cypher.runWrite(cypher :: STRING?, params :: MAP?) :: (value :: MAP?) ¦apoc.cypher.runFirstColumn(cypher :: STRING?, params :: MAP?, expectMultipleValues = true :: BOOLEAN?) :: (ANY?) ¦apoc.cypher.runFirstColumnMany(cypher :: STRING?, params :: MAP?) :: (LIST? OF ANY?) ¦apoc.cypher.runFirstColumnSingle(cypher :: STRING?, params :: MAP?) :: (ANY?) diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.csv b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.csv index e2592317a2..87b729b006 100644 --- a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.csv +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.csv @@ -8,9 +8,11 @@ ¦procedure¦apoc.cypher.runFile¦apoc.cypher.runFile(file :: STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runFile(file or url,[{statistics:true,timeout:10,parameters:{}}]) - runs each statement in the file, all semicolon separated - currently no schema operations ¦procedure¦apoc.cypher.runFiles¦apoc.cypher.runFiles(file :: LIST? OF STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runFiles([files or urls],[{statistics:true,timeout:10,parameters:{}}])) - runs each statement in the files, all semicolon separated ¦procedure¦apoc.cypher.runMany¦apoc.cypher.runMany(cypher :: STRING?, params :: MAP?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runMany('cypher;\nstatements;',\{params},[{statistics:true,timeout:10}]) - runs each semicolon separated statement and returns summary - currently no schema operations +¦procedure¦apoc.cypher.runSchema¦apoc.cypher.runSchema(cypher :: STRING?, params :: MAP?) :: (value :: MAP?)¦apoc.cypher.runSchema(fragment, params) yield value - executes query schema fragment with the given parameters ¦procedure¦apoc.cypher.runSchemaFile¦apoc.cypher.runSchemaFile(file :: STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runSchemaFile(file or url,[{statistics:true,timeout:10}]) - allows only schema operations, runs each schema statement in the file, all semicolon separated ¦procedure¦apoc.cypher.runSchemaFiles¦apoc.cypher.runSchemaFiles(file :: LIST? OF STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runSchemaFiles([files or urls],{statistics:true,timeout:10}) - allows only schema operations, runs each schema statement in the files, all semicolon separated ¦procedure¦apoc.cypher.runTimeboxed¦apoc.cypher.runTimeboxed(cypher :: STRING?, params :: MAP?, timeout :: INTEGER?) :: (value :: MAP?)¦apoc.cypher.runTimeboxed('cypherStatement',\{params}, timeout) - abort kernelTransaction after timeout ms if not finished +¦procedure¦apoc.cypher.runWrite¦apoc.cypher.runWrite(cypher :: STRING?, params :: MAP?) :: (value :: MAP?)¦apoc.cypher.runWrite(fragment, params) yield value - alias for apoc.cypher.doIt ¦function¦apoc.cypher.runFirstColumn¦apoc.cypher.runFirstColumn(cypher :: STRING?, params :: MAP?, expectMultipleValues = true :: BOOLEAN?) :: (ANY?)¦use either apoc.cypher.runFirstColumnMany for a list return or apoc.cypher.runFirstColumnSingle for returning the first row of the first column ¦function¦apoc.cypher.runFirstColumnMany¦apoc.cypher.runFirstColumnMany(cypher :: STRING?, params :: MAP?) :: (LIST? OF ANY?)¦apoc.cypher.runFirstColumnMany(statement, params) - executes statement with given parameters, returns first column only collected into a list, params are available as identifiers ¦function¦apoc.cypher.runFirstColumnSingle¦apoc.cypher.runFirstColumnSingle(cypher :: STRING?, params :: MAP?) :: (ANY?)¦apoc.cypher.runFirstColumnSingle(statement, params) - executes statement with given parameters, returns first element of the first column only, params are available as identifiers diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema-lite.csv b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema-lite.csv new file mode 100644 index 0000000000..a5fb5bfaaf --- /dev/null +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema-lite.csv @@ -0,0 +1,2 @@ +¦signature +¦apoc.cypher.runSchema(cypher :: STRING?, params :: MAP?) :: (value :: MAP?) diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema.adoc b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema.adoc new file mode 100644 index 0000000000..1d11d46e6b --- /dev/null +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runSchema.adoc @@ -0,0 +1,5 @@ +¦xref::overview/apoc.cypher/apoc.cypher.runSchema.adoc[apoc.cypher.runSchema icon:book[]] + + +`apoc.cypher.runSchema(fragment, params) yield value` - executes query schema fragment with the given parameters +¦label:procedure[] +¦label:apoc-core[] diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite-lite.csv b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite-lite.csv new file mode 100644 index 0000000000..2087aa09a0 --- /dev/null +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite-lite.csv @@ -0,0 +1,2 @@ +¦signature +¦apoc.cypher.runWrite(cypher :: STRING?, params :: MAP?) :: (value :: MAP?) diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite.adoc b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite.adoc new file mode 100644 index 0000000000..a9cda81deb --- /dev/null +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/apoc.cypher.runWrite.adoc @@ -0,0 +1,5 @@ +¦xref::overview/apoc.cypher/apoc.cypher.runWrite.adoc[apoc.cypher.runWrite icon:book[]] + + +`apoc.cypher.runWrite(fragment, params) yield value` - alias for apoc.cypher.doIt +¦label:procedure[] +¦label:apoc-core[] diff --git a/docs/asciidoc/modules/ROOT/examples/generated-documentation/documentation.csv b/docs/asciidoc/modules/ROOT/examples/generated-documentation/documentation.csv index 7c3c29cc70..6bf53ac385 100644 --- a/docs/asciidoc/modules/ROOT/examples/generated-documentation/documentation.csv +++ b/docs/asciidoc/modules/ROOT/examples/generated-documentation/documentation.csv @@ -70,9 +70,11 @@ ¦procedure¦apoc.cypher.runFile¦apoc.cypher.runFile(file :: STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runFile(file or url,[{statistics:true,timeout:10,parameters:{}}]) - runs each statement in the file, all semicolon separated - currently no schema operations¦false¦xref::cypher-execution/index.adoc ¦procedure¦apoc.cypher.runFiles¦apoc.cypher.runFiles(file :: LIST? OF STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runFiles([files or urls],[{statistics:true,timeout:10,parameters:{}}])) - runs each statement in the files, all semicolon separated¦false¦xref::cypher-execution/index.adoc ¦procedure¦apoc.cypher.runMany¦apoc.cypher.runMany(cypher :: STRING?, params :: MAP?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runMany('cypher;\nstatements;',\{params},[{statistics:true,timeout:10}]) - runs each semicolon separated statement and returns summary - currently no schema operations¦true¦xref::cypher-execution/index.adoc +¦procedure¦apoc.cypher.runSchema¦apoc.cypher.runSchema(cypher :: STRING?, params :: MAP?) :: (value :: MAP?)¦apoc.cypher.runSchema(fragment, params) yield value - executes query schema fragment with the given parameters¦true¦xref::cypher-execution/index.adoc ¦procedure¦apoc.cypher.runSchemaFile¦apoc.cypher.runSchemaFile(file :: STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runSchemaFile(file or url,[{statistics:true,timeout:10}]) - allows only schema operations, runs each schema statement in the file, all semicolon separated¦false¦xref::cypher-execution/index.adoc ¦procedure¦apoc.cypher.runSchemaFiles¦apoc.cypher.runSchemaFiles(file :: LIST? OF STRING?, config = {} :: MAP?) :: (row :: INTEGER?, result :: MAP?)¦apoc.cypher.runSchemaFiles([files or urls],{statistics:true,timeout:10}) - allows only schema operations, runs each schema statement in the files, all semicolon separated¦false¦xref::cypher-execution/index.adoc ¦procedure¦apoc.cypher.runTimeboxed¦apoc.cypher.runTimeboxed(cypher :: STRING?, params :: MAP?, timeout :: INTEGER?) :: (value :: MAP?)¦apoc.cypher.runTimeboxed('cypherStatement',\{params}, timeout) - abort kernelTransaction after timeout ms if not finished¦true¦xref::cypher-execution/index.adoc +¦procedure¦apoc.cypher.runWrite¦apoc.cypher.runWrite(cypher :: STRING?, params :: MAP?) :: (value :: MAP?)¦apoc.cypher.runWrite(fragment, params) yield value - alias for apoc.cypher.doIt¦true¦xref::cypher-execution/index.adoc ¦procedure¦apoc.date.expire¦apoc.date.expire(node :: NODE?, time :: INTEGER?, timeUnit :: STRING?) :: VOID¦CALL apoc.date.expire(node,time,'time-unit') - expire node at specified time by setting :TTL label and `ttl` property¦false¦ ¦procedure¦apoc.date.expireIn¦apoc.date.expireIn(node :: NODE?, timeDelta :: INTEGER?, timeUnit :: STRING?) :: VOID¦CALL apoc.date.expireIn(node,time,'time-unit') - expire node after specified length of time time by setting :TTL label and `ttl` property¦false¦ ¦procedure¦apoc.do.case¦apoc.do.case(conditionals :: LIST? OF ANY?, elseQuery = :: STRING?, params = {} :: MAP?) :: (value :: MAP?)¦apoc.do.case([condition, query, condition, query, ...], elseQuery:'', params:{}) yield value - given a list of conditional / writing query pairs, executes the query associated with the first conditional evaluating to true (or the else query if none are true) with the given parameters¦true¦xref::cypher-execution/conditionals.adoc diff --git a/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runSchema.adoc b/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runSchema.adoc new file mode 100644 index 0000000000..613bc06d69 --- /dev/null +++ b/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runSchema.adoc @@ -0,0 +1,40 @@ +//// +This file is generated by DocsTest, so don't change it! +//// + += apoc.cypher.runSchema +:description: This section contains reference documentation for the apoc.cypher.runSchema procedure. + +label:procedure[] label:apoc-core[] + +[.emphasis] +apoc.cypher.runSchema(fragment, params) yield value - executes query schema fragment with the given parameters + +== Signature + +[source] +---- +apoc.cypher.runSchema(cypher :: STRING?, params :: MAP?) :: (value :: MAP?) +---- + +== Input parameters +[.procedures, opts=header] +|=== +| Name | Type | Default +|cypher|STRING?|null +|params|MAP?|null +|=== + +== Output parameters +[.procedures, opts=header] +|=== +| Name | Type +|value|MAP? +|=== + +[[usage-apoc.cypher.runSchema]] +== Usage Examples +include::partial$usage/apoc.cypher.runSchema.adoc[] + +xref::cypher-execution/index.adoc[More documentation of apoc.cypher.runSchema,role=more information] + diff --git a/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runWrite.adoc b/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runWrite.adoc new file mode 100644 index 0000000000..dbffeeeb88 --- /dev/null +++ b/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/apoc.cypher.runWrite.adoc @@ -0,0 +1,36 @@ +//// +This file is generated by DocsTest, so don't change it! +//// + += apoc.cypher.runWrite +:description: This section contains reference documentation for the apoc.cypher.runWrite procedure. + +label:procedure[] label:apoc-core[] + +[.emphasis] +apoc.cypher.runWrite(fragment, params) yield value - alias for apoc.cypher.doIt + +== Signature + +[source] +---- +apoc.cypher.runWrite(cypher :: STRING?, params :: MAP?) :: (value :: MAP?) +---- + +== Input parameters +[.procedures, opts=header] +|=== +| Name | Type | Default +|cypher|STRING?|null +|params|MAP?|null +|=== + +== Output parameters +[.procedures, opts=header] +|=== +| Name | Type +|value|MAP? +|=== + +xref::cypher-execution/index.adoc[More documentation of apoc.cypher.runWrite,role=more information] + diff --git a/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/index.adoc b/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/index.adoc index 528bed6038..03967b5a90 100644 --- a/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/index.adoc +++ b/docs/asciidoc/modules/ROOT/pages/overview/apoc.cypher/index.adoc @@ -53,6 +53,11 @@ apoc.cypher.runFiles([files or urls],[{statistics:true,timeout:10,parameters:{}} apoc.cypher.runMany('cypher;\nstatements;',\{params},[{statistics:true,timeout:10}]) - runs each semicolon separated statement and returns summary - currently no schema operations |label:procedure[] |label:apoc-core[] +|xref::overview/apoc.cypher/apoc.cypher.runSchema.adoc[apoc.cypher.runSchema icon:book[]] + +apoc.cypher.runSchema(fragment, params) yield value - executes query schema fragment with the given parameters +|label:procedure[] +|label:apoc-core[] |xref::overview/apoc.cypher/apoc.cypher.runSchemaFile.adoc[apoc.cypher.runSchemaFile icon:book[]] apoc.cypher.runSchemaFile(file or url,[{statistics:true,timeout:10}]) - allows only schema operations, runs each schema statement in the file, all semicolon separated @@ -68,6 +73,11 @@ apoc.cypher.runSchemaFiles([files or urls],{statistics:true,timeout:10}) - allow apoc.cypher.runTimeboxed('cypherStatement',\{params}, timeout) - abort kernelTransaction after timeout ms if not finished |label:procedure[] |label:apoc-core[] +|xref::overview/apoc.cypher/apoc.cypher.runWrite.adoc[apoc.cypher.runWrite icon:book[]] + +apoc.cypher.runWrite(fragment, params) yield value - alias for apoc.cypher.doIt +|label:procedure[] +|label:apoc-core[] |xref::overview/apoc.cypher/apoc.cypher.runFirstColumn.adoc[apoc.cypher.runFirstColumn icon:book[]] use either apoc.cypher.runFirstColumnMany for a list return or apoc.cypher.runFirstColumnSingle for returning the first row of the first column diff --git a/docs/asciidoc/modules/ROOT/partials/generated-documentation/documentation.adoc b/docs/asciidoc/modules/ROOT/partials/generated-documentation/documentation.adoc index 3fb2d80e40..c93800376c 100644 --- a/docs/asciidoc/modules/ROOT/partials/generated-documentation/documentation.adoc +++ b/docs/asciidoc/modules/ROOT/partials/generated-documentation/documentation.adoc @@ -910,6 +910,11 @@ apoc.cypher.runFiles([files or urls],[{statistics:true,timeout:10,parameters:{}} apoc.cypher.runMany('cypher;\nstatements;',\{params},[{statistics:true,timeout:10}]) - runs each semicolon separated statement and returns summary - currently no schema operations |label:procedure[] |label:apoc-core[] +|xref::overview/apoc.cypher/apoc.cypher.runSchema.adoc[apoc.cypher.runSchema icon:book[]] + +apoc.cypher.runSchema(fragment, params) yield value - executes query schema fragment with the given parameters +|label:procedure[] +|label:apoc-core[] |xref::overview/apoc.cypher/apoc.cypher.runSchemaFile.adoc[apoc.cypher.runSchemaFile icon:book[]] apoc.cypher.runSchemaFile(file or url,[{statistics:true,timeout:10}]) - allows only schema operations, runs each schema statement in the file, all semicolon separated @@ -925,6 +930,11 @@ apoc.cypher.runSchemaFiles([files or urls],{statistics:true,timeout:10}) - allow apoc.cypher.runTimeboxed('cypherStatement',\{params}, timeout) - abort kernelTransaction after timeout ms if not finished |label:procedure[] |label:apoc-core[] +|xref::overview/apoc.cypher/apoc.cypher.runWrite.adoc[apoc.cypher.runWrite icon:book[]] + +apoc.cypher.runWrite(fragment, params) yield value - alias for apoc.cypher.doIt +|label:procedure[] +|label:apoc-core[] |xref::overview/apoc.cypher/apoc.cypher.runFirstColumn.adoc[apoc.cypher.runFirstColumn icon:book[]] use either apoc.cypher.runFirstColumnMany for a list return or apoc.cypher.runFirstColumnSingle for returning the first row of the first column diff --git a/docs/asciidoc/modules/ROOT/partials/generated-documentation/nav.adoc b/docs/asciidoc/modules/ROOT/partials/generated-documentation/nav.adoc index 3d016b6a5a..3053fecc9e 100644 --- a/docs/asciidoc/modules/ROOT/partials/generated-documentation/nav.adoc +++ b/docs/asciidoc/modules/ROOT/partials/generated-documentation/nav.adoc @@ -177,9 +177,11 @@ This file is generated by DocsTest, so don't change it! *** xref::overview/apoc.cypher/apoc.cypher.runFile.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runFiles.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runMany.adoc[] +*** xref::overview/apoc.cypher/apoc.cypher.runSchema.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runSchemaFile.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runSchemaFiles.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runTimeboxed.adoc[] +*** xref::overview/apoc.cypher/apoc.cypher.runWrite.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runFirstColumn.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runFirstColumnMany.adoc[] *** xref::overview/apoc.cypher/apoc.cypher.runFirstColumnSingle.adoc[] diff --git a/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.doIt.adoc b/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.doIt.adoc index 5b71e801e7..35a12fa5ae 100644 --- a/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.doIt.adoc +++ b/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.doIt.adoc @@ -54,3 +54,5 @@ RETURN value; | {node: (:Tag)} | {node: (:Location)} |=== + +Please note that if you want to use schema operation, you have to use xref::overview/apoc.cypher/apoc.cypher.runSchema.adoc[apoc.cypher.runSchema] procedure diff --git a/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.runSchema.adoc b/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.runSchema.adoc new file mode 100644 index 0000000000..4b43bc609f --- /dev/null +++ b/docs/asciidoc/modules/ROOT/partials/usage/apoc.cypher.runSchema.adoc @@ -0,0 +1,11 @@ +[source,cypher] +---- +CALL apoc.cypher.runSchema('CREATE INDEX test FOR (w:Test) ON (w.$name)',{}) +---- + +or + +[source,cypher] +---- +CALL apoc.cypher.runSchema('CREATE CONSTRAINT $name ON (w:Test) ASSERT w.baz IS UNIQUE',{}) +---- \ No newline at end of file