- 修复 MySql AsTreeCte cte_path 可能长度过短问题;

This commit is contained in:
2881099 2023-09-19 14:54:40 +08:00
parent 3cb53df5a5
commit 6d483a5ad9

View File

@ -733,6 +733,7 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
} }
var sql1ctePath = ""; var sql1ctePath = "";
var wct2ctePath = "";
if (pathSelector != null) if (pathSelector != null)
{ {
select._tables[0].Parameter = pathSelector?.Parameters[0]; select._tables[0].Parameter = pathSelector?.Parameters[0];
@ -750,9 +751,18 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
case DataType.Firebird: case DataType.Firebird:
case DataType.ClickHouse: 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); 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; break;
default: default:
sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null); sql1ctePath = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
wct2ctePath = sql1ctePath;
break; break;
} }
sql1ctePath = $"{sql1ctePath} as cte_path, "; sql1ctePath = $"{sql1ctePath} as cte_path, ";
@ -770,7 +780,6 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
if (pathSelector != null) if (pathSelector != null)
{ {
select._tables[0].Parameter = pathSelector?.Parameters[0]; 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( sql2ctePath = select._commonUtils.StringConcat(
new string[] { new string[] {
up == false ? "wct1.cte_path" : wct2ctePath, up == false ? "wct1.cte_path" : wct2ctePath,