From bd431efc1daf4dd1482228614da524f95c1cedec Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 5 Jul 2017 07:51:36 +0800 Subject: [PATCH] Mysql Page Bug --- Src/Asp.Net/MySqlTest/Demos/1_Query.cs | 2 +- Src/Asp.Net/MySqlTest/UnitTest/Query/SingleQuery.cs | 6 +++--- Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs | 4 ++-- .../Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Src/Asp.Net/MySqlTest/Demos/1_Query.cs b/Src/Asp.Net/MySqlTest/Demos/1_Query.cs index d49c90dd2..915da3535 100644 --- a/Src/Asp.Net/MySqlTest/Demos/1_Query.cs +++ b/Src/Asp.Net/MySqlTest/Demos/1_Query.cs @@ -182,7 +182,7 @@ namespace OrmTest.Demo public static void Page() { var db = GetInstance(); - var pageIndex = 1; + var pageIndex = 2; var pageSize = 2; var totalCount = 0; //page diff --git a/Src/Asp.Net/MySqlTest/UnitTest/Query/SingleQuery.cs b/Src/Asp.Net/MySqlTest/UnitTest/Query/SingleQuery.cs index e384189bb..1fba52c0d 100644 --- a/Src/Asp.Net/MySqlTest/UnitTest/Query/SingleQuery.cs +++ b/Src/Asp.Net/MySqlTest/UnitTest/Query/SingleQuery.cs @@ -42,12 +42,12 @@ namespace OrmTest.UnitTest base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` ORDER BY `ID` ASC LIMIT 1,3", null, t4.Key, null, "single t4 Error"); var t5 = db.Queryable().OrderBy(it => it.Id).Skip(3).ToSql(); - base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` LIMIT 4,9223372036854775807", null, t5.Key,null, "single t5 Error"); + base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` LIMIT 3,9223372036854775807", null, t5.Key,null, "single t5 Error"); int pageIndex = 2; int pageSize = 10; var t6 = db.Queryable().OrderBy(it => it.Id,OrderByType.Desc).Skip((pageIndex-1)*pageSize).Take(pageSize).ToSql(); - base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` ORDER BY `ID` DESC LIMIT 11,10", null, t6.Key, null, "single t6 Error"); + base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` ORDER BY `ID` DESC LIMIT 10,10", null, t6.Key, null, "single t6 Error"); int studentCount=db.Ado.GetInt("select count(1) from Student"); @@ -95,7 +95,7 @@ namespace OrmTest.UnitTest .Where(it=>it.Id==1) .WhereIF(true,it=> SqlFunc.Contains(it.Name,"a")) .OrderBy(it => it.Id, OrderByType.Desc).Skip((pageIndex - 1) * pageSize).Take(pageSize ).With(SqlWith.NoLock).ToSql(); - base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` WHERE ( `ID` = @Id0 ) AND (`Name` like concat('%',@MethodConst1,'%')) ORDER BY `ID` DESC LIMIT 11,10", new List() { + base.Check(@"SELECT `ID`,`SchoolId`,`Name`,`CreateTime` FROM `STudent` WHERE ( `ID` = @Id0 ) AND (`Name` like concat('%',@MethodConst1,'%')) ORDER BY `ID` DESC LIMIT 10,10", new List() { new SugarParameter("@Id0",1),new SugarParameter("@MethodConst1","a") }, t8.Key, t8.Value,"single t8 Error"); diff --git a/Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs b/Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs index c561e6963..f5bf1e63c 100644 --- a/Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs +++ b/Src/Asp.Net/SqlSugar/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.1.0.8")] -[assembly: AssemblyFileVersion("4.1.0.8")] +[assembly: AssemblyVersion("4.1.0.9")] +[assembly: AssemblyFileVersion("4.1.0.9")] diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs index 1eea18d2e..78a856aa9 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs @@ -37,7 +37,7 @@ namespace SqlSugar if (Skip != null && Take == null) { if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0]; - return string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString, Skip.ObjToInt() + 1, long.MaxValue); + return string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString, Skip.ObjToInt(), long.MaxValue); } else if (Skip == null && Take != null) { @@ -47,7 +47,7 @@ namespace SqlSugar else if (Skip != null && Take != null) { if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0]; - return string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() + 1 : 0, Take); + return string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt(): 0, Take); } else {