Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade nova #65

Merged
merged 7 commits into from Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -206,7 +206,7 @@ Objects<Person>().DeleteAll();
- `String.StartsWith`
- `String.EndsWith`
- `IEnumerable.Contains` method in LINQ queries
- `DbHelper.GetObjectNo` method in LINQ queries
- `Db.GetOid` method in LINQ queries
- `IS` operator by using `is` operator in LINQ queries
- `OFFSET` clause by using `IQueryable.Skip` method
- `FETCH` clause by using methods:
Expand Down
2 changes: 1 addition & 1 deletion src/Starcounter.Linq/KnownMethods.cs
Expand Up @@ -76,7 +76,7 @@ internal static class KnownMethods
private static readonly IQueryable<int> IQueryable = null;
private static readonly object obj = new object();

public static readonly MethodInfo GetObjectNo = MethodFromExample(() => obj.GetObjectNo());
public static readonly MethodInfo GetOid = MethodFromExample(() => Db.GetOid(obj));
public static readonly MethodInfo ObjectEquals = MethodFromExample(() => obj.Equals(null));
public static readonly MethodInfo EnumerableContains = MethodFromExample(() => Enumerable.Contains(0));
public static readonly MethodInfo StringContains = MethodFromExample(() => "".Contains(""));
Expand Down
2 changes: 1 addition & 1 deletion src/Starcounter.Linq/Starcounter.Linq.csproj
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Starcounter.Nova" Version="0.10.1-alpha-*" />
<PackageReference Include="Starcounter.Nova" Version="0.11.0-*" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Starcounter.Linq/Visitors/OrderByVisitor.cs
Expand Up @@ -18,7 +18,7 @@ public override void VisitMember(MemberExpression node, QueryBuilder<TEntity> st

public override void VisitMethodCall(MethodCallExpression node, QueryBuilder<TEntity> state)
{
if (node.Method == KnownMethods.GetObjectNo)
if (node.Method == KnownMethods.GetOid)
{
state.WriteOrderByObjectNo();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Starcounter.Linq/Visitors/WhereVisitor.cs
Expand Up @@ -299,7 +299,7 @@ public override void VisitMethodCall(MethodCallExpression node, QueryBuilder<TEn
AddConstantOrMemberNodeValue(node, state);
state.WriteWhere(" LIKE '%' || ?)");
}
else if (node.Method == KnownMethods.GetObjectNo)
else if (node.Method == KnownMethods.GetOid)
{
state.WriteWhereObjectNo();
}
Expand Down Expand Up @@ -395,7 +395,7 @@ public override void VisitUnary(UnaryExpression node, QueryBuilder<TEntity> stat
else
{
Visit(node.Operand, state);
}
}
}

public override void VisitTypeBinary(TypeBinaryExpression node, QueryBuilder<TEntity> state)
Expand Down
Expand Up @@ -8,12 +8,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="Starcounter.Nova" Version="0.10.1-alpha-*" />
<PackageReference Include="Starcounter.Nova.Bluestar" Version="0.10.1-alpha-*" />
<PackageReference Include="Starcounter.Nova.Options" Version="0.10.1-alpha-*" />
<PackageReference Include="Starcounter.Nova.Hosting" Version="0.10.1-alpha-*" />
<PackageReference Include="Starcounter.Nova.Hosting" Version="0.11.0-*" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="runtime.native.Starcounter.Bluestar2" Version="2.0.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

Expand All @@ -25,8 +23,4 @@
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="runtime.native.Starcounter.Bluestar" Version="2.4.0-pre-013035" />
</ItemGroup>

</Project>
20 changes: 11 additions & 9 deletions test/Starcounter.Linq.QueryTests/Tests/FilteringTests.cs
Expand Up @@ -381,14 +381,15 @@ public void FirstOrDefault_IntegerNotInArray__AdHoc()
[Theory]
[InlineData(Mode.AdHoc)]
[InlineData(Mode.CompiledQuery)]
public void WhereObjectNoEqual(Mode mode)
public void WhereOidEqual(Mode mode)
{
Db.Transact(() =>
{
ulong testPersonId = Db.SQL<Person>($"SELECT p FROM {typeof(Person)} p WHERE p.Name = ?", "Roger").First().GetObjectNo();
var testPerson = Db.SQL<Person>($"SELECT p FROM {typeof(Person)} p WHERE p.Name = ?", "Roger").First();
ulong testPersonId = Db.GetOid(testPerson);
var persons = mode == Mode.CompiledQuery
? CompileQuery((ulong id) => Objects<Person>().Where(p => p.GetObjectNo() == id))(testPersonId).ToList()
: Objects<Person>().Where(p => p.GetObjectNo() == testPersonId).ToList();
? CompileQuery((ulong id) => Objects<Person>().Where(p => Db.GetOid(p) == id))(testPersonId).ToList()
: Objects<Person>().Where(p => Db.GetOid(p) == testPersonId).ToList();

Assert.Single(persons);
Assert.Equal("Roger", persons.First().Name);
Expand All @@ -398,14 +399,15 @@ public void WhereObjectNoEqual(Mode mode)
[Theory]
[InlineData(Mode.AdHoc)]
[InlineData(Mode.CompiledQuery)]
public void WhereObjectNoNotEqualWithOtherPredicate(Mode mode)
public void WhereOidNotEqualWithOtherPredicate(Mode mode)
{
Db.Transact(() =>
{
ulong testPersonId = Db.SQL<Person>($"SELECT p FROM {typeof(Person)} p WHERE p.Name = ?", "Roger").First().GetObjectNo();
var testPerson = Db.SQL<Person>($"SELECT p FROM {typeof(Person)} p WHERE p.Name = ?", "Roger").First();
ulong testPersonOid = Db.GetOid(testPerson);
var persons = mode == Mode.CompiledQuery
? CompileQuery((ulong id, string name) => Objects<Person>().Where(p => p.GetObjectNo() != id && p.Name == name))(testPersonId, "Anton").ToList()
: Objects<Person>().Where(p => p.GetObjectNo() != testPersonId && p.Name == "Anton").ToList();
? CompileQuery((ulong id, string name) => Objects<Person>().Where(p => Db.GetOid(p) != id && p.Name == name))(testPersonOid, "Anton").ToList()
: Objects<Person>().Where(p => Db.GetOid(p) != testPersonOid && p.Name == "Anton").ToList();

Assert.Single(persons);
Assert.NotEqual("Roger", persons.First().Name);
Expand Down Expand Up @@ -512,4 +514,4 @@ public string GetName(int val1, string val2)
}
}
}
}
}
10 changes: 5 additions & 5 deletions test/Starcounter.Linq.QueryTests/Tests/PagingTests.cs
Expand Up @@ -55,22 +55,22 @@ public void OrderBy(Mode mode)
? CompileQuery(() => Objects<Person>().OrderBy(x => x.Age))().ToList()
: Objects<Person>().OrderBy(x => x.Age).ToList();
Assert.Equal(2, people.Count);
Assert.True(people[0].GetObjectNo() < people[1].GetObjectNo());
Assert.True(Db.GetOid(people[0]) < Db.GetOid(people[1]));
});
}

[Theory]
[InlineData(Mode.AdHoc)]
[InlineData(Mode.CompiledQuery)]
public void OrderBy_ObjectNo(Mode mode)
public void OrderBy_Oid(Mode mode)
{
Db.Transact(() =>
{
List<Person> people = mode == Mode.CompiledQuery
? CompileQuery(() => Objects<Person>().OrderByDescending(x => x.GetObjectNo()))().ToList()
: Objects<Person>().OrderByDescending(x => x.GetObjectNo()).ToList();
? CompileQuery(() => Objects<Person>().OrderByDescending(x => Db.GetOid(x)))().ToList()
: Objects<Person>().OrderByDescending(x => Db.GetOid(x)).ToList();
Assert.Equal(2, people.Count);
Assert.True(people[0].GetObjectNo() > people[1].GetObjectNo());
Assert.True(Db.GetOid(people[0]) > Db.GetOid(people[1]));
});
}
}
Expand Down