mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 修复 ClickHouse 数组类型 hasAny 与 In 解析冲突问题;#1699
This commit is contained in:
		@@ -152,17 +152,23 @@ namespace FreeSql.ClickHouse
 | 
			
		||||
                                if (left.StartsWith("(") || left.EndsWith(")")) left = $"array[{left.TrimStart('(').TrimEnd(')')}]";
 | 
			
		||||
                                return $"(case when {left} is null then 0 else length({left}) end > 0)";
 | 
			
		||||
                            case "Contains":
 | 
			
		||||
                                tsc.SetMapColumnTmp(null);
 | 
			
		||||
                                var args1 = getExp(callExp.Arguments[argIndex]);
 | 
			
		||||
                                var oldMapType = tsc.SetMapTypeReturnOld(tsc.mapTypeTmp);
 | 
			
		||||
                                var oldDbParams = objExp?.NodeType == ExpressionType.MemberAccess ? tsc.SetDbParamsReturnOld(null) : null; //#900 UseGenerateCommandParameterWithLambda(true) 子查询 bug、以及 #1173 参数化 bug
 | 
			
		||||
                                tsc.isNotSetMapColumnTmp = true;
 | 
			
		||||
                                left = objExp == null ? null : getExp(objExp);
 | 
			
		||||
                                tsc.isNotSetMapColumnTmp = false;
 | 
			
		||||
                                tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
 | 
			
		||||
                                if (oldDbParams != null) tsc.SetDbParamsReturnOld(oldDbParams);
 | 
			
		||||
                                if (left.StartsWith("(") || left.EndsWith(")")) left = $"array[{left.TrimStart('(').TrimEnd(')')}]";
 | 
			
		||||
                                return $"(hasAny({left}, [{args1}]))";
 | 
			
		||||
								tsc.SetMapColumnTmp(null);
 | 
			
		||||
								var args1 = getExp(callExp.Arguments[argIndex]);
 | 
			
		||||
								var oldMapType = tsc.SetMapTypeReturnOld(tsc.mapTypeTmp);
 | 
			
		||||
								var oldDbParams = objExp?.NodeType == ExpressionType.MemberAccess ? tsc.SetDbParamsReturnOld(null) : null; //#900 UseGenerateCommandParameterWithLambda(true) 子查询 bug、以及 #1173 参数化 bug
 | 
			
		||||
								tsc.isNotSetMapColumnTmp = true;
 | 
			
		||||
								left = objExp == null ? null : getExp(objExp);
 | 
			
		||||
								tsc.isNotSetMapColumnTmp = false;
 | 
			
		||||
								tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
 | 
			
		||||
								if (oldDbParams != null) tsc.SetDbParamsReturnOld(oldDbParams);
 | 
			
		||||
								//判断 in 或 hasAny
 | 
			
		||||
								if (left.StartsWith("array[") && left.EndsWith("]"))
 | 
			
		||||
									return $"({args1}) in ({left.Substring(6, left.Length - 7)})";
 | 
			
		||||
								if (left.StartsWith("(") && left.EndsWith(")")) //在各大 Provider AdoProvider 中已约定,500元素分割, 3空格\r\n4空格
 | 
			
		||||
									return $"(({args1}) in {left.Replace(",   \r\n    \r\n", $") \r\n OR ({args1}) in (")})";
 | 
			
		||||
								if (args1.StartsWith("(") && args1.EndsWith(")")) args1 = $"[{args1.TrimStart('(').TrimEnd(')')}]";
 | 
			
		||||
								else args1 = $"[{args1}]";
 | 
			
		||||
								return $"(hasAny({left}, {args1}))";
 | 
			
		||||
                            case "Concat":
 | 
			
		||||
                                left = objExp == null ? null : getExp(objExp);
 | 
			
		||||
                                if (left.StartsWith("(") || left.EndsWith(")")) left = $"array[{left.TrimStart('(').TrimEnd(')')}]";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user