- 修复 AsTable 子查询未传播的 bug;#1103

This commit is contained in:
2881099
2022-06-09 13:59:27 +08:00
parent 7e2b0526c5
commit 38c6796b67
14 changed files with 109 additions and 100 deletions

View File

@ -12,26 +12,6 @@ namespace FreeSql.Tests.Odbc.Default
public class OdbcCodeFirstTest
{
[Fact]
public void Test_0String()
{
var fsql = g.odbc;
fsql.Delete<test_0string01>().Where("1=1").ExecuteAffrows();
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).ExecuteAffrows());
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).NoneParameter().ExecuteAffrows());
var list = fsql.Select<test_0string01>().ToList();
Assert.Equal(2, list.Count);
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[0].name);
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[1].name);
}
class test_0string01
{
public Guid id { get; set; }
public string name { get; set; }
}
[Fact]
public void _字段()
{

View File

@ -1126,6 +1126,24 @@ WHERE (((cast(a.""Id"" as character)) in (SELECT b.""Title""
[Fact]
public void AsTable()
{
var fsql = g.sqlite;
var asTableSubSql = fsql.Select<TestTypeParentInfo>().AsTable((_, old) => $"{old}_01").ToSql(a => new
{
a.Id,
max = fsql.Select<TestTypeInfo>().Max(b => b.Guid),
any = a.Types.Any(b => b.Name == "xx"),
any2 = a.Types.AsSelect().Any(b => b.Name == "xx"),
sub = fsql.Select<TestTypeInfo>().Where(b => b.Guid == a.Id).ToList()
});
Assert.Equal(@"SELECT a.""Id"" as1, ifnull((SELECT max(a.""Guid"")
FROM ""TestTypeInfo_01"" a), 0) as2, exists(SELECT 1
FROM ""TestTypeInfo_01"" b
WHERE (b.""ParentId"" = a.""Id"") AND (b.""Name"" = 'xx')
limit 0,1) as3, exists(SELECT 1
FROM ""TestTypeInfo_01"" b
WHERE (b.""Name"" = 'xx') AND (b.""ParentId"" = a.""Id"")
limit 0,1) as4
FROM ""TestTypeParentInfo_01"" a", asTableSubSql);
var listt = select.AsTable((a, b) => "(select * from tb_topic where clicks > 10)").Page(1, 10).ToList();