public async Task SelectPageSqlTest() { using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig); SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectPageTestRequest); var sqlStr = await producer.GetSqlStrTest(); Assert.AreEqual(sqlStr.Replace(" ", " ").Trim(), "SELECT [Uid],[Name] FROM [User] ORDER BY [Uid] Asc OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY"); }
public async Task SelectFieldSqlTest() { using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig); SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectFieldTestRequest); var sqlStr = await producer.GetSqlStrTest(); Assert.AreEqual(sqlStr.Replace(" ", " ").Trim(), "SELECT TOP 20 [Uid],[Name] FROM [User]"); }
public async Task SelectNullSqlTest() { using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig); SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectNullTestRequest); var sqlStr = await producer.GetSqlStrTest(); Assert.AreEqual(sqlStr.Replace(" ", " ").Trim(), "SELECT [Name] FROM [User] WHERE [Phone] IS NULL"); }
public async Task SelectSqlTest() { using Sqless sqless = new Sqless(SelectConfig); SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, SelectRequest); var sqlStr = await producer.GetSqlStrTest(); Assert.AreEqual(sqlStr.Replace(" ", " ").Trim(), "SELECT TOP 2 [Name],[Price] FROM [Product]"); }
public async Task RightJoinSqlTest() { var request = JoinRequest; request.Joins[0].SqlessJoinType = SqlessJoinType.RightJoin; using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig); SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, request); var sqlStr = await producer.GetSqlStrTest(); Assert.AreEqual(sqlStr.Replace(" ", " ").Trim(), "SELECT [User].[Name],[User].[Uid],[Order].[Time] FROM [User] RIGHT JOIN [Order] ON [User].[Uid] = [Order].[Uid] WHERE [User].[Phone] IS NOT NULL"); }
public async Task AccessSelectSqlTest() { var request = new SqlessSelectRequest() { Table = Tables.User, PageSize = 2, Fields = new List <Query.SqlessField> { new Query.SqlessField() { Field = "Name" } } }; using Sqless sqless = new Sqless(Global.GetOwnerAccessConfig("1")); SqlessSelectSqlBuilder producer = new SqlessSelectSqlBuilder(sqless, request); var sqlStr = await producer.GetSqlStrTest(); Assert.AreEqual(sqlStr.Replace(" ", " ").Trim(), "SELECT TOP 2 [Name] FROM [User] WHERE [User].[Uid] = '1'"); }