Skip to content
This repository
Browse code

Don't use ApplyLimit with With clauses

  • Loading branch information...
commit 4583cee0cc9579508c25c23dfc1a4a8cc8fbafc7 1 parent 0a5a4fb
Mark Rendle authored
4  CommonAssemblyInfo.cs
@@ -19,6 +19,6 @@
19 19
 // COM, set the ComVisible attribute to true on that type.
20 20
 [assembly: ComVisible(false)]
21 21
 
22  
-[assembly: AssemblyVersion("0.17.1.1")]
23  
-[assembly: AssemblyFileVersion("0.17.1.1")]
  22
+[assembly: AssemblyVersion("0.18.0.0")]
  23
+[assembly: AssemblyFileVersion("0.18.0.0")]
24 24
 
13  Simple.Data.Ado/AdoAdapterQueryRunner.cs
@@ -151,7 +151,7 @@ public AdoAdapterQueryRunner(AdoAdapter adapter, AdoAdapterTransaction transacti
151 151
                 }
152 152
                 else
153 153
                 {
154  
-                    ApplyPaging(commandBuilders, mainCommandBuilder, skipClause, takeClause, queryPager);
  154
+                    ApplyPaging(commandBuilders, mainCommandBuilder, skipClause, takeClause, query.Clauses.OfType<WithClause>().Any(), queryPager);
155 155
                 }
156 156
             }
157 157
             return commandBuilders.ToArray();
@@ -168,21 +168,20 @@ public AdoAdapterQueryRunner(AdoAdapter adapter, AdoAdapterTransaction transacti
168 168
             commandBuilders.Add(commandBuilder);
169 169
         }
170 170
 
171  
-        private void ApplyPaging(List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause,
172  
-                                 TakeClause takeClause, IQueryPager queryPager)
  171
+        private void ApplyPaging(List<ICommandBuilder> commandBuilders, ICommandBuilder mainCommandBuilder, SkipClause skipClause, TakeClause takeClause, bool hasWithClause, IQueryPager queryPager)
173 172
         {
174 173
             const int maxInt = 2147483646;
175 174
 
176 175
             IEnumerable<string> commandTexts;
177  
-            if (skipClause == null)
  176
+            if (skipClause == null && !hasWithClause)
178 177
             {
179 178
                 commandTexts = queryPager.ApplyLimit(mainCommandBuilder.Text, takeClause.Count);
180 179
             }
181 180
             else
182 181
             {
183  
-                if (takeClause == null) takeClause = new TakeClause(maxInt);
184  
-                commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skipClause.Count,
185  
-                                                      takeClause.Count);
  182
+                int skip = skipClause == null ? 0 : skipClause.Count;
  183
+                int take = takeClause == null ? maxInt : takeClause.Count;
  184
+                commandTexts = queryPager.ApplyPaging(mainCommandBuilder.Text, skip, take);
186 185
             }
187 186
 
188 187
             commandBuilders.AddRange(
1  Simple.Data.InMemoryTest/Simple.Data.InMemoryTest.csproj
@@ -60,6 +60,7 @@
60 60
     <Compile Include="InMemoryTests.cs" />
61 61
     <Compile Include="NameResolutionTest.cs" />
62 62
     <Compile Include="Properties\AssemblyInfo.cs" />
  63
+    <Compile Include="SimpleQueryConversionTests.cs" />
63 64
   </ItemGroup>
64 65
   <ItemGroup>
65 66
     <None Include="packages.config" />

0 notes on commit 4583cee

Please sign in to comment.
Something went wrong with that request. Please try again.