Skip to content

Commit 888acf6

Browse files
committed
If there is a limit clause, the limit is always -1 if not specified to ensure that correct SQL is generated.
1 parent a204788 commit 888acf6

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

SQLitePCL.pretty.Orm/SqlQuery.Limit.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public static partial class SqlQuery
1414
public sealed class LimitClause<T> : ISqlQuery
1515
{
1616
private readonly OrderByClause<T> orderBy;
17-
private readonly Nullable<int> limit;
17+
private readonly int limit;
1818
private readonly Nullable<int> offset;
1919

20-
internal LimitClause(OrderByClause<T> orderBy, Nullable<int> limit, Nullable<int> offset)
20+
internal LimitClause(OrderByClause<T> orderBy, int limit, Nullable<int> offset)
2121
{
2222
this.orderBy = orderBy;
2323
this.limit = limit;
@@ -54,7 +54,7 @@ public override string ToString()
5454
{
5555
return
5656
orderBy.ToString() +
57-
(limit.HasValue ? "\r\nLIMIT " + limit.Value : "" ) +
57+
"\r\nLIMIT " + limit +
5858
(offset.HasValue ? "\r\nOFFSET " + offset.Value : "");
5959
}
6060
}

SQLitePCL.pretty.Orm/SqlQuery.OrderBy.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public LimitClause<T> Take(int n)
6868
public LimitClause<T> Skip(int n)
6969
{
7070
Contract.Requires(n >= 0);
71-
return new LimitClause<T>(this, null, n);
71+
72+
//If the LIMIT expression evaluates to a negative value, then there is no upper bound on the number of rows returned
73+
return new LimitClause<T>(this, -1, n);
7274
}
7375

7476
/// <summary>

0 commit comments

Comments
 (0)