Skip to content

Commit

Permalink
Add != AutoQuery Implicit Convention
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Oct 19, 2015
1 parent b8b2e16 commit 78cb85c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ServiceStack.Server/AutoQueryFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class AutoQueryFeature : IPlugin, IPostInitPlugin
public const string GreaterThanFormat = "{Field} > {Value}";
public const string LessThanFormat = "{Field} < {Value}";
public const string LessThanOrEqualFormat = "{Field} <= {Value}";

public const string NotEqualFormat = "{Field} <> {Value}";

public Dictionary<string, string> ImplicitConventions = new Dictionary<string, string>
{
{"%Above%", GreaterThanFormat},
Expand All @@ -68,11 +69,13 @@ public class AutoQueryFeature : IPlugin, IPostInitPlugin
{"%Higher%", GreaterThanOrEqualFormat},
{">%", GreaterThanOrEqualFormat},
{"%>", GreaterThanFormat},
{"%!", NotEqualFormat},

{"%GreaterThanOrEqualTo%", GreaterThanOrEqualFormat},
{"%GreaterThan%", GreaterThanFormat},
{"%LessThan%", LessThanFormat},
{"%LessThanOrEqualTo%", LessThanOrEqualFormat},
{"%NotEqualTo", NotEqualFormat},

{"Behind%", LessThanFormat},
{"%Below%", LessThanFormat},
Expand Down Expand Up @@ -122,6 +125,7 @@ public AutoQueryFeature()
ImplicitConventions = new List<Property>
{
new Property { Name = "=", Value = "%"},
new Property { Name = "!=", Value = "%!"},
new Property { Name = ">=", Value = ">%"},
new Property { Name = ">", Value = "%>"},
new Property { Name = "<=", Value = "%<"},
Expand Down
4 changes: 4 additions & 0 deletions tests/ServiceStack.WebHost.Endpoints.Tests/AutoQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,8 @@ public void Can_execute_implicit_conventions()
Assert.That(response.Results.Count, Is.EqualTo(3));
response = baseUrl.AddQueryParam("GreaterThanAge", 42).AsJsonInto<Rockstar>();
Assert.That(response.Results.Count, Is.EqualTo(3));
response = baseUrl.AddQueryParam("AgeNotEqualTo", 27).AsJsonInto<Rockstar>();
Assert.That(response.Results.Count, Is.EqualTo(4));

response = baseUrl.AddQueryParam(">Age", 42).AsJsonInto<Rockstar>();
Assert.That(response.Results.Count, Is.EqualTo(4));
Expand All @@ -885,6 +887,8 @@ public void Can_execute_implicit_conventions()
Assert.That(response.Results.Count, Is.EqualTo(3));
response = baseUrl.AddQueryParam("Age<", 42).AsJsonInto<Rockstar>();
Assert.That(response.Results.Count, Is.EqualTo(4));
response = baseUrl.AddQueryParam("Age!", "27").AsJsonInto<Rockstar>();
Assert.That(response.Results.Count, Is.EqualTo(4));

response = baseUrl.AddQueryParam("FirstNameStartsWith", "jim").AsJsonInto<Rockstar>();
Assert.That(response.Results.Count, Is.EqualTo(2));
Expand Down

0 comments on commit 78cb85c

Please sign in to comment.