Skip to content

Commit

Permalink
Merge pull request #973 from Azure/revert-902-master
Browse files Browse the repository at this point in the history
Revert "Escape data strings for odata queries."
  • Loading branch information
Hovsep committed Apr 22, 2016
2 parents a7b6eb9 + 1e0252d commit f76e16f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,7 @@ public void AzureODataTests()
Top = 10,
OrderBy = "id"
};
var filterString = Uri.EscapeDataString("id gt 5 and name eq 'foo'");
Assert.Equal(string.Format("$filter={0}&$orderby=id&$top=10", filterString), filter.ToString());
Assert.Equal("$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10", filter.ToString());
client.Odata.GetWithFilter(filter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,14 @@ public void EncodingTheParameters()
[Fact]
public void ODataQuerySupportsAllParameters()
{
var queryString = "foo eq 'bar'";
var query = new ODataQuery<Param1>(p => p.Foo == "bar")
{
Expand = "param1",
OrderBy = "d",
Skip = 10,
Top = 100
};
Assert.Equal(string.Format("$filter={0}&$orderby=d&$expand=param1&$top=100&$skip=10", Uri.EscapeDataString(queryString)), query.ToString());
Assert.Equal("$filter=foo eq 'bar'&$orderby=d&$expand=param1&$top=100&$skip=10", query.ToString());
}

[Fact]
Expand All @@ -260,38 +259,34 @@ public void ODataQuerySupportsEmptyState()
[Fact]
public void ODataQuerySupportsPartialState()
{
var queryString = "foo eq 'bar'";
var query = new ODataQuery<Param1>(p => p.Foo == "bar")
{
Top = 100
};
Assert.Equal(string.Format("$filter={0}&$top=100", Uri.EscapeDataString(queryString)), query.ToString());
Assert.Equal("$filter=foo eq 'bar'&$top=100", query.ToString());
}

[Fact]
public void ODataQuerySupportsImplicitConversionFromFilterString()
{
var queryString = "foo eq 'bar'";
ODataQuery<Param1> query = queryString;
ODataQuery<Param1> query = "foo eq 'bar'";
query.Top = 100;
Assert.Equal(string.Format("$filter={0}&$top=100", Uri.EscapeDataString(queryString)), query.ToString());
Assert.Equal("$filter=foo eq 'bar'&$top=100", query.ToString());
}

[Fact]
public void ODataQuerySupportsImplicitConversionFromFullFilterString()
{
var queryString = "foo eq 'bar'";
ODataQuery<Param1> query = string.Format("$filter={0}", queryString);
ODataQuery<Param1> query = "$filter=foo eq 'bar'";
query.Top = 100;
Assert.Equal(string.Format("$filter={0}&$top=100", Uri.EscapeDataString(queryString)), query.ToString());
Assert.Equal("$filter=foo eq 'bar'&$top=100", query.ToString());
}

[Fact]
public void ODataQuerySupportsImplicitConversionFromQueryString()
{
var queryString = "foo eq 'bar'";
ODataQuery<Param1> query = string.Format("$filter={0}&$top=100", queryString);
Assert.Equal(string.Format("$filter={0}&$top=100", Uri.EscapeDataString(queryString)), query.ToString());
ODataQuery<Param1> query = "$filter=foo eq 'bar'&$top=100";
Assert.Equal("$filter=foo eq 'bar'&$top=100", query.ToString());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ public override string ToString()
if (!string.IsNullOrEmpty(Filter))
{
queryStringList.Add(string.Format(CultureInfo.InvariantCulture,
"$filter={0}", Uri.EscapeDataString(Filter)));
"$filter={0}", Filter));
}
if (!string.IsNullOrEmpty(OrderBy))
{
queryStringList.Add(string.Format(CultureInfo.InvariantCulture,
"$orderby={0}", Uri.EscapeDataString(OrderBy)));
"$orderby={0}", OrderBy));
}
if (!string.IsNullOrEmpty(Expand))
{
queryStringList.Add(string.Format(CultureInfo.InvariantCulture,
"$expand={0}", Uri.EscapeDataString(Expand)));
"$expand={0}", Expand));
}
if (Top != null)
{
Expand Down

0 comments on commit f76e16f

Please sign in to comment.