mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-03-11 08:30:56 +08:00
GBase在条件执行DateTime相关操作的异常修复
This commit is contained in:
@@ -400,17 +400,24 @@ namespace FreeSql.Tests.GBaseExpression
|
||||
data.Add(select.Where(a => a.CreateTime.AddMilliseconds(1) > DateTime.Now).ToList());
|
||||
data.Add(select.Where(a => a.Type.Time.AddMilliseconds(1) > DateTime.Now).ToList());
|
||||
data.Add(select.Where(a => a.Type.Parent.Time2.AddMilliseconds(1) > DateTime.Now).ToList());
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a.`Title` as4, a.`CreateTime` as5
|
||||
//FROM `tb_topic111333` a
|
||||
//WHERE (date_add(a.`CreateTime`, interval (1) * 1000 microsecond) > now());
|
||||
// SELECT a.Id, a.Clicks, a.TypeGuid, a.Title, a.CreateTime,(a.CreateTime + ((1)/1000) units fraction)
|
||||
// FROM tb_topic111333 a
|
||||
// WHERE ((a.CreateTime + ((1)/1000) units fraction) > current)
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type
|
||||
//WHERE (date_add(a__Type.`Time`, interval (1) * 1000 microsecond) > now());
|
||||
|
||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a__Type.`Time` as7, a.`Title` as8, a.`CreateTime` as9
|
||||
//FROM `tb_topic111333` a, `TestTypeInfo333` a__Type, `TestTypeParentInfo23123` a__Type__Parent
|
||||
//WHERE (date_add(a__Type__Parent.`Time2`, interval (1) * 1000 microsecond) > now())
|
||||
// SELECT a.Id, a.Clicks, a.TypeGuid, a__Type.Guid, a__Type.ParentId, a__Type.Name, a__Type.Time, a.Title, a.CreateTime
|
||||
// FROM tb_topic111333 a
|
||||
// LEFT JOIN TestTypeInfo333 a__Type ON a__Type.Guid = a.TypeGuid
|
||||
// WHERE ((a__Type.Time + ((1)/1000) units fraction) > current)
|
||||
|
||||
// SELECT a.Id, a.Clicks, a.TypeGuid, a__Type.Guid, a__Type.ParentId, a__Type.Name, a__Type.Time, a.Title, a.CreateTime
|
||||
// FROM tb_topic111333 a
|
||||
// LEFT JOIN TestTypeInfo333 a__Type ON a__Type.Guid = a.TypeGuid
|
||||
// LEFT JOIN TestTypeParentInf1 a__Type__Parent ON a__Type__Parent.Id = a__Type.ParentId
|
||||
// WHERE ((a__Type__Parent.Time2 + ((1)/1000) units fraction) > current)
|
||||
}
|
||||
[Fact]
|
||||
public void AddMinutes()
|
||||
|
||||
@@ -375,13 +375,15 @@ namespace FreeSql.GBase
|
||||
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
|
||||
{
|
||||
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
|
||||
var d1 = getExp(date1);
|
||||
var d2 = getExp(date2);
|
||||
switch (memberName)
|
||||
{
|
||||
case "TotalDays": return $"({getExp(date1)}-{getExp(date2)})";
|
||||
case "TotalHours": return $"(({getExp(date1)}-{getExp(date2)})*24)";
|
||||
case "TotalMilliseconds": return $"(({getExp(date1)}-{getExp(date2)})*{24 * 60 * 60 * 1000})";
|
||||
case "TotalMinutes": return $"(({getExp(date1)}-{getExp(date2)})*{24 * 60})";
|
||||
case "TotalSeconds": return $"(({getExp(date1)}-{getExp(date2)})*{24 * 60 * 60})";
|
||||
case "TotalDays": return $"(({d1}-{d2}) / (1 units day))";
|
||||
case "TotalHours": return $"(({d1}-{d2}) / (1 units hour))";
|
||||
case "TotalMilliseconds": return $"((({d1}-{d2}) / (1 units fraction)) / 1000)";
|
||||
case "TotalMinutes": return $"(({d1}-{d2}) / (1 units minute))";
|
||||
case "TotalSeconds": return $"(({d1}-{d2}) / (1 units second))";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -414,11 +416,11 @@ namespace FreeSql.GBase
|
||||
{
|
||||
case "AddDays": return $"({left} + ({args1}) units day)";
|
||||
case "AddHours": return $"({left} + ({args1}) units hour)";
|
||||
case "AddMilliseconds": return $"({left} + ({args1})/1000 units fraction)";
|
||||
case "AddMilliseconds": return $"({left} + (({args1})/1000) units fraction)";
|
||||
case "AddMinutes": return $"({left} + ({args1}) units minute)";
|
||||
case "AddMonths": return $"({left} + ({args1}) units month)";
|
||||
case "AddSeconds": return $"({left} + ({args1}) units second)";
|
||||
case "AddTicks": return $"({left} + ({args1})/10000000 units fraction)";
|
||||
case "AddTicks": return $"({left} + (({args1})/10000000) units fraction)";
|
||||
case "AddYears": return $"({left} + ({args1}) units year)";
|
||||
case "Subtract":
|
||||
switch ((exp.Arguments[0].Type.IsNullableType() ? exp.Arguments[0].Type.GetGenericArguments().FirstOrDefault() : exp.Arguments[0].Type).FullName)
|
||||
|
||||
Reference in New Issue
Block a user