Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
patriksvensson committed Sep 11, 2018
2 parents 5226c79 + fe2b42d commit 7e36e08
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 31 deletions.
24 changes: 14 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ appsettings.Development.json
*.sln.ide/

# Rider
src/.idea/**/workspace.xml
src/.idea/**/tasks.xml
src/.idea/dictionaries
src/.idea/**/dataSources/
src/.idea/**/dataSources.ids
src/.idea/**/dataSources.xml
src/.idea/**/dataSources.local.xml
src/.idea/**/sqlDataSources.xml
src/.idea/**/dynamic.xml
src/.idea/**/uiDesigner.xml
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml


## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
### New in 0.9.0 (Released 2018/09/11)

- [__#21__](https://github.com/spectresystems/spectre.query/issues/21) Can't parse integer/decimal followed by a closing parenthesis

### New in 0.8.0 (Released 2018/09/11)

- [__#18__](https://github.com/spectresystems/spectre.query/issues/18) Support querying of collections
- [__#21__](https://github.com/spectresystems/spectre.query/issues/21) Can't parse integer/decimal followed by a closing parenthesis

### New in 0.7.0 (Released 2018/08/21)

Expand Down
1 change: 1 addition & 0 deletions src/.idea/.idea.Spectre.Query/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/.idea/.idea.Spectre.Query/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/.idea.Spectre.Query/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/.idea/.idea.Spectre.Query/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Spectre.Query.Tests/Infrastructure/IssueAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace Spectre.Query.Tests.Infrastructure
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class IssueAttribute : Attribute
{
public string Url { get; }

public IssueAttribute(string url)
{
Url = url;
}
}
}
40 changes: 23 additions & 17 deletions src/Spectre.Query.Tests/QueryProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ await TestQueryRunner.Execute("Foo = 1", DefaultSeeder, options =>
options.Configure<Document>(document =>
{
document.Map("Foo", e => e.DocumentId);
document.Map<Invoice>(invoice =>
{
invoice.Map("Foo", e => e.Cancelled);
});
document.Map<Invoice>(invoice => { invoice.Map("Foo", e => e.Cancelled); });
});
});
});
Expand All @@ -66,16 +63,14 @@ public async Task Should_Throw_If_Trying_To_Map_Navigational_Property_Directly()
// Given, When
var result = await Record.ExceptionAsync(async () =>
{
await TestQueryRunner.Execute("Foo = 'Contoso'", DefaultSeeder, options =>
{
options.Configure<Document>(document =>
await TestQueryRunner.Execute("Foo = 'Contoso'", DefaultSeeder,
options =>
{
document.Map<Invoice>(invoice =>
options.Configure<Document>(document =>
{
invoice.Map("Foo", e => e.Company);
document.Map<Invoice>(invoice => { invoice.Map("Foo", e => e.Company); });
});
});
});
});

// Then
Expand All @@ -90,16 +85,14 @@ public async Task Should_Throw_If_Trying_To_Map_Non_Entity_Type_Property()
// Given, When
var result = await Record.ExceptionAsync(async () =>
{
await TestQueryRunner.Execute("Foo = 'Contoso'", DefaultSeeder, options =>
{
options.Configure<Document>(document =>
await TestQueryRunner.Execute("Foo = 'Contoso'", DefaultSeeder,
options =>
{
document.Map<Invoice>(invoice =>
options.Configure<Document>(document =>
{
invoice.Map("Foo", e => e.Dummy);
document.Map<Invoice>(invoice => { invoice.Map("Foo", e => e.Dummy); });
});
});
});
});

// Then
Expand Down Expand Up @@ -275,6 +268,19 @@ public async Task Should_Throw_If_Decimal_Has_Invalid_Format(string query)
.ShouldBeOfType<InvalidOperationException>()
.And().Message.ShouldBe("Invalid number format.");
}

[Theory]
[Issue("https://github.com/spectresystems/spectre.query/issues/21")]
[InlineData("(Discount = 20)", new int[] { 4 })]
[InlineData("(Discount = 20.0)", new int[] { 4 })]
public async Task Should_Parse_Number_Followed_By_Parenthesis(string query, int[] expected)
{
// Given, When
var result = await TestQueryRunner.Execute(query, DefaultSeeder);

// Then
result.ShouldContainEntities(expected);
}
}
}
}
}
4 changes: 4 additions & 0 deletions src/Spectre.Query.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBePrivate_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedAutoPropertyAccessor_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String></wpf:ResourceDictionary>
10 changes: 7 additions & 3 deletions src/Spectre.Query/Internal/Expressions/Tokenization/Tokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ private Token ReadNumber(int position, bool negative)
accumulator.Append(ReadInteger());
}

// More non-whitespace tokens?
if (_buffer.CanRead && !char.IsWhiteSpace(_buffer.Peek()))
if (_buffer.CanRead)
{
throw new InvalidOperationException("Invalid number format.");
// More non-whitespace tokens?
var next = _buffer.Peek();
if (!char.IsWhiteSpace(next) && next != ')')
{
throw new InvalidOperationException("Invalid number format.");
}
}

var value = accumulator.ToString();
Expand Down

0 comments on commit 7e36e08

Please sign in to comment.