- 修复 3.2.801 AsTreeCte cte_path 别名问题;

This commit is contained in:
2881099 2023-10-10 03:39:42 +08:00
parent 94fa653ec9
commit 117568178e

View File

@ -733,7 +733,7 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
} }
var sql1ctePath = ""; var sql1ctePath = "";
var wct2ctePath = ""; string wct2ctePath = null;
if (pathSelector != null) if (pathSelector != null)
{ {
select._tables[0].Parameter = pathSelector?.Parameters[0]; select._tables[0].Parameter = pathSelector?.Parameters[0];
@ -751,7 +751,6 @@ 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 = select._commonExpression.ExpressionWhereLambda(select._tables, select._tableRule, pathSelector?.Body, select._diymemexpWithTempQuery, null, null);
break; break;
case DataType.MySql: case DataType.MySql:
case DataType.OdbcMySql: case DataType.OdbcMySql:
@ -762,7 +761,6 @@ JOIN {select._commonUtils.QuoteSqlName(tbDbName)} a ON cte_tbc.cte_id = a.{selec
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, ";
@ -780,6 +778,8 @@ 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];
if (wct2ctePath == null)
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,