public void ShouldApplyLimitWithoutOffsetUsingOrderBy() { const string sql = "select a,b,c from d where a = 1 order by c"; const string expected = "select a,b,c from d where a = 1 order by c limit 10"; var modified = new SqliteQueryPager().ApplyLimit(sql, 10).Single(); modified = Normalize.Replace(modified, " ").ToLowerInvariant(); Assert.AreEqual(expected,modified); }
public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered() { const string sql = "select a,b,c from d where a = 1"; const string expected = "select a,b,c from d where a = 1 order by a limit 5,10"; var modified = new SqliteQueryPager().ApplyPaging(sql, null, 5, 10).Single(); modified = Normalize.Replace(modified, " ").ToLowerInvariant(); Assert.AreEqual(expected, modified); }
public void ShouldApplyPagingUsingOrderBy() { const string sql = "select a,b,c from d where a = 1 order by c"; const string expected = "select a,b,c from d where a = 1 order by c limit @skip,@take"; var modified = new SqliteQueryPager().ApplyPaging(sql, "@skip", "@take"); modified = Normalize.Replace(modified, " ").ToLowerInvariant(); Assert.AreEqual(expected, modified); }
public void ShouldApplyPagingUsingOrderByFromQueryClauseAndIgnoringKeys() { const string sql = "select a,b,c from d where a = 1 order by c"; const string expected = "select a,b,c from d where a = 1 order by c limit 5,10"; string[] keys = new[] { "c", "b" }; var modified = new SqliteQueryPager().ApplyPaging(sql, keys, 5, 10).Single(); modified = Normalize.Replace(modified, " ").ToLowerInvariant(); Assert.AreEqual(expected, modified); }