Permalink
Browse files

Don't use ApplyLimit with With clauses

  • Loading branch information...
1 parent 0a5a4fb commit 4583cee0cc9579508c25c23dfc1a4a8cc8fbafc7 @markrendle committed Aug 29, 2012
@@ -19,6 +19,6 @@
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("0.17.1.1")]
-[assembly: AssemblyFileVersion("0.17.1.1")]
+[assembly: AssemblyVersion("0.18.0.0")]
+[assembly: AssemblyFileVersion("0.18.0.0")]
@@ -151,7 +151,7 @@ public AdoAdapterQueryRunner(AdoAdapter adapter, AdoAdapterTransaction transacti
}
else
{
- ApplyPaging(commandBuilders, mainCommandBuilder, skipClause, takeClause, queryPager);
+ ApplyPaging(commandBuilders, mainCommandBuilder, skipClause, takeClause, query.Clauses.OfType<WithClause>().Any(), queryPager);
}
}
return commandBuilders.ToArray();
@@ -168,21 +168,20 @@ public AdoAdapterQueryRunner(AdoAdapter adapter, AdoAdapterTransaction transacti
commandBuilders.Add(commandBuilder);
}
- private void ApplyPaging(List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause,
- TakeClause takeClause, IQueryPager queryPager)
+ private void ApplyPaging(List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager)
{
const int maxInt = 2147483646;
IEnumerable<string> commandTexts;
- if (skipClause == null)
+ if (skipClause == null && !hasWithClause)
{
commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count);
}
else
{
- if (takeClause == null) takeClause = new TakeClause(maxInt);
- commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skipClause.Count,
- takeClause.Count);
+ int skip = skipClause == null ? 0 : skipClause.Count;
+ int take = takeClause == null ? maxInt : takeClause.Count;
+ commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skip, take);
}
commandBuilders.AddRange(
@@ -60,6 +60,7 @@
<Compile Include="InMemoryTests.cs" />
<Compile Include="NameResolutionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SimpleQueryConversionTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

0 comments on commit 4583cee

Please sign in to comment.