From bb84c28aeb52796f864e8986ba1c7034c24ddbb2 Mon Sep 17 00:00:00 2001 From: Chris Skardon Date: Fri, 5 Dec 2014 10:11:19 +0000 Subject: [PATCH] Adds the ability for a user to pass free text to the ParserVersion call, giving the ability to use things like `2.1.experimental`, fixes issue #73 --- Neo4jClient/Cypher/CypherFluentQuery.cs | 9 +++++++-- Neo4jClient/Cypher/ICypherFluentQuery.cs | 1 + .../CypherFluentQueryParserVersionTests.cs | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Neo4jClient/Cypher/CypherFluentQuery.cs b/Neo4jClient/Cypher/CypherFluentQuery.cs index 1e7afacd0..0680dbca5 100644 --- a/Neo4jClient/Cypher/CypherFluentQuery.cs +++ b/Neo4jClient/Cypher/CypherFluentQuery.cs @@ -353,12 +353,17 @@ IGraphClient IAttachedReference.Client get { return Client; } } + public ICypherFluentQuery ParserVersion(string version) + { + return Mutate(w => w.AppendClause(string.Format("CYPHER {0}", version))); + } + public ICypherFluentQuery ParserVersion(Version version) { if (version < minimumCypherParserVersion) - return Mutate(w => w.AppendClause("CYPHER LEGACY")); + return ParserVersion("LEGACY"); - return Mutate(w => w.AppendClause(string.Format("CYPHER {0}.{1}", version.Major, version.Minor))); + return ParserVersion(string.Format("{0}.{1}", version.Major, version.Minor)); } public ICypherFluentQuery ParserVersion(int major, int minor) diff --git a/Neo4jClient/Cypher/ICypherFluentQuery.cs b/Neo4jClient/Cypher/ICypherFluentQuery.cs index 1aaff38f2..b2e8da768 100644 --- a/Neo4jClient/Cypher/ICypherFluentQuery.cs +++ b/Neo4jClient/Cypher/ICypherFluentQuery.cs @@ -14,6 +14,7 @@ public partial interface ICypherFluentQuery ICypherFluentQuery WithParams(IDictionary parameters); ICypherFluentQuery WithParams(object parameters); + ICypherFluentQuery ParserVersion(string version); ICypherFluentQuery ParserVersion(Version version); ICypherFluentQuery ParserVersion(int major, int minor); diff --git a/Test/Cypher/CypherFluentQueryParserVersionTests.cs b/Test/Cypher/CypherFluentQueryParserVersionTests.cs index de9f54ec1..4a92ce26c 100644 --- a/Test/Cypher/CypherFluentQueryParserVersionTests.cs +++ b/Test/Cypher/CypherFluentQueryParserVersionTests.cs @@ -7,6 +7,23 @@ namespace Neo4jClient.Test.Cypher { public class CypherFluentQueryParserVersionTests { + [Test] + public void SetsVersionToFreeTextGiven() + { + var client = Substitute.For(); + var query = new CypherFluentQuery(client) + .ParserVersion("2.1.experimental") + .Start(new + { + n = All.Nodes, + }) + .Return("n") + .Query; + + Assert.AreEqual("CYPHER 2.1.experimental\r\nSTART n=node(*)\r\nRETURN n", query.QueryText); + Assert.AreEqual(0, query.QueryParameters.Count); + } + [Test] public void SetsVersion_WhenUsingVersionOverload() {