mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 20:38:16 +08:00
- 修复 IUpdate.Set 表达式解析的 bug;
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||
<Version>0.6.12</Version>
|
||||
<Version>0.6.13</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
||||
|
@ -278,40 +278,51 @@ namespace FreeSql.Internal {
|
||||
};
|
||||
public string ExpressionWhereLambdaNoneForeignObject(List<SelectTableInfo> _tables, TableInfo table, List<SelectColumnInfo> _selectColumnMap, Expression exp, Func<Expression[], string> getSelectGroupingMapString) {
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _selectColumnMap = _selectColumnMap, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, currentTable = table });
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && exp.Type == typeof(bool) && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
var isBool = exp.Type.NullableTypeOrThis() == typeof(bool);
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && isBool && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
return $"{sql} = {formatSql(true, null)}";
|
||||
switch (sql) {
|
||||
case "1":
|
||||
case "'t'": return "1=1";
|
||||
case "0":
|
||||
case "'f'": return "1=2";
|
||||
default:return sql;
|
||||
if (isBool) {
|
||||
switch (sql) {
|
||||
case "1":
|
||||
case "'t'": return "1=1";
|
||||
case "0":
|
||||
case "'f'": return "1=2";
|
||||
default: return sql;
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
public string ExpressionWhereLambda(List<SelectTableInfo> _tables, Expression exp, Func<Expression[], string> getSelectGroupingMapString) {
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where });
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && exp.Type == typeof(bool) && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
var isBool = exp.Type.NullableTypeOrThis() == typeof(bool);
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && isBool && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
return $"{sql} = {formatSql(true, null)}";
|
||||
switch (sql) {
|
||||
case "1":
|
||||
case "'t'": return "1=1";
|
||||
case "0":
|
||||
case "'f'": return "1=2";
|
||||
default: return sql;
|
||||
if (isBool) {
|
||||
switch (sql) {
|
||||
case "1":
|
||||
case "'t'": return "1=1";
|
||||
case "0":
|
||||
case "'f'": return "1=2";
|
||||
default: return sql;
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
public void ExpressionJoinLambda(List<SelectTableInfo> _tables, SelectTableInfoType tbtype, Expression exp, Func<Expression[], string> getSelectGroupingMapString) {
|
||||
var tbidx = _tables.Count;
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = tbtype, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where });
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && exp.Type == typeof(bool) && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
var isBool = exp.Type.NullableTypeOrThis() == typeof(bool);
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && isBool && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
sql = $"{sql} = {formatSql(true, null)}";
|
||||
switch (sql) {
|
||||
case "1":
|
||||
case "'t'": sql = "1=1"; break;
|
||||
case "0":
|
||||
case "'f'": sql = "1=2"; break;
|
||||
default: break;
|
||||
if (isBool) {
|
||||
switch (sql) {
|
||||
case "1":
|
||||
case "'t'": sql = "1=1"; break;
|
||||
case "0":
|
||||
case "'f'": sql = "1=2"; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (_tables.Count > tbidx) {
|
||||
_tables[tbidx].Type = tbtype;
|
||||
|
@ -358,7 +358,7 @@ namespace FreeSql.Internal.CommonProvider {
|
||||
var memberName = initExp.Bindings[a].Member.Name;
|
||||
if (_table.ColumnsByCsIgnore.ContainsKey(memberName)) continue;
|
||||
if (_table.ColumnsByCs.TryGetValue(memberName, out var col) == false) throw new Exception($"找不到属性:{memberName}");
|
||||
var memberValue = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, initAssignExp.Expression, null);
|
||||
var memberValue = _commonExpression.ExpressionLambdaToSql(initAssignExp.Expression, new CommonExpression.ExpTSC { });
|
||||
_setIncr.Append(", ").Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ").Append(memberValue);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user