Skip to content

Commit

Permalink
- 修复 MySql AsTreeCte cte_path 可能长度过短问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Sep 19, 2023
1 parent 3cb53df commit 6d483a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion FreeSql/Extensions/FreeSqlGlobalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ WHERE @cte_ids IS NOT NULL
}

var sql1ctePath = "";
var wct2ctePath = "";
if (pathSelector != null)
{
select._tables[0].Parameter = pathSelector?.Parameters[0];
Expand All @@ -750,9 +751,18 @@ WHERE @cte_ids IS NOT NULL
case DataType.Firebird:
case DataType.ClickHouse:
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, Expression.Call(typeof(Convert).GetMethod("ToString", new Type[] { typeof(string) }), pathSelector?.Body), select._diymemexpWithTempQuery, null, null);
wct2ctePath = sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
break;
case DataType.MySql:
case DataType.OdbcMySql:
case DataType.CustomMySql:
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
sql1ctePath = $"CAST({sql1ctePath} as char(2000))";
wct2ctePath = sql1ctePath;
break;
default:
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
wct2ctePath = sql1ctePath;
break;
}
sql1ctePath = $"{sql1ctePath} as cte_path, ";
Expand All @@ -770,7 +780,6 @@ WHERE @cte_ids IS NOT NULL
if (pathSelector != null)
{
select._tables[0].Parameter = pathSelector?.Parameters[0];
var wct2ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
sql2ctePath = select._commonUtils.StringConcat(
new string[] {
up == false ? "wct1.cte_path" : wct2ctePath,
Expand Down

0 comments on commit 6d483a5

Please sign in to comment.