Skip to content

Commit

Permalink
Add free text to parserversion call
Browse files Browse the repository at this point in the history
Pull #77
  • Loading branch information
Chris Skardon committed Aug 14, 2015
2 parents 2d87448 + bb84c28 commit bdc1c45
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Neo4jClient.Tests/Cypher/CypherFluentQueryParserVersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ namespace Neo4jClient.Test.Cypher
{
public class CypherFluentQueryParserVersionTests
{
[Test]
public void SetsVersionToFreeTextGiven()
{
var client = Substitute.For<IRawGraphClient>();
var query = new CypherFluentQuery(client)
.ParserVersion("2.1.experimental")
.Start(new
{
n = All.Nodes,
})
.Return<object>("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()
{
Expand Down
9 changes: 7 additions & 2 deletions Neo4jClient/Cypher/CypherFluentQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,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)
Expand Down
1 change: 1 addition & 0 deletions Neo4jClient/Cypher/ICypherFluentQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial interface ICypherFluentQuery
ICypherFluentQuery WithParams(IDictionary<string,object> parameters);
ICypherFluentQuery WithParams(object parameters);

ICypherFluentQuery ParserVersion(string version);
ICypherFluentQuery ParserVersion(Version version);
ICypherFluentQuery ParserVersion(int major, int minor);

Expand Down

0 comments on commit bdc1c45

Please sign in to comment.