mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 01:05:27 +08:00 
			
		
		
		
	- 优化 LIKE 表达式解析 #1870; - 移除 OdbcDameng/OdbcKingbaseES;
This commit is contained in:
		@@ -352,8 +352,9 @@ namespace FreeSql.KingbaseES
 | 
			
		||||
                    case "StartsWith":
 | 
			
		||||
                    case "EndsWith":
 | 
			
		||||
                    case "Contains":
 | 
			
		||||
                        var leftLike = exp.Object.NodeType == ExpressionType.MemberAccess ? left : $"({left})";
 | 
			
		||||
                        var args0Value = getExp(exp.Arguments[0]);
 | 
			
		||||
                        if (args0Value == "NULL") return $"({left}) IS NULL";
 | 
			
		||||
                        if (args0Value == "NULL") return $"{leftLike} IS NULL";
 | 
			
		||||
                        if (args0Value.Contains("%"))
 | 
			
		||||
                        {
 | 
			
		||||
                            if (exp.Method.Name == "StartsWith") return $"strpos({left}, {args0Value}) = 1";
 | 
			
		||||
@@ -366,10 +367,10 @@ namespace FreeSql.KingbaseES
 | 
			
		||||
                            if (exp.Arguments[1].Type == typeof(bool) ||
 | 
			
		||||
                                exp.Arguments[1].Type == typeof(StringComparison)) likeOpt = "ILIKE";
 | 
			
		||||
                        }
 | 
			
		||||
                        if (exp.Method.Name == "StartsWith") return $"({left}) {likeOpt} {(args0Value.EndsWith("'") ? args0Value.Insert(args0Value.Length - 1, "%") : $"(({args0Value})::text || '%')")}";
 | 
			
		||||
                        if (exp.Method.Name == "EndsWith") return $"({left}) {likeOpt} {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"('%' || ({args0Value})::text)")}";
 | 
			
		||||
                        if (args0Value.StartsWith("'") && args0Value.EndsWith("'")) return $"({left}) {likeOpt} {args0Value.Insert(1, "%").Insert(args0Value.Length, "%")}";
 | 
			
		||||
                        return $"({left}) {likeOpt} ('%' || ({args0Value})::text || '%')";
 | 
			
		||||
                        if (exp.Method.Name == "StartsWith") return $"{leftLike} {likeOpt} {(args0Value.EndsWith("'") ? args0Value.Insert(args0Value.Length - 1, "%") : $"(({args0Value})::text || '%')")}";
 | 
			
		||||
                        if (exp.Method.Name == "EndsWith") return $"{leftLike} {likeOpt} {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"('%' || ({args0Value})::text)")}";
 | 
			
		||||
                        if (args0Value.StartsWith("'") && args0Value.EndsWith("'")) return $"{leftLike} {likeOpt} {args0Value.Insert(1, "%").Insert(args0Value.Length, "%")}";
 | 
			
		||||
                        return $"{leftLike} {likeOpt} ('%' || ({args0Value})::text || '%')";
 | 
			
		||||
                    case "ToLower": return $"lower({left})";
 | 
			
		||||
                    case "ToUpper": return $"upper({left})";
 | 
			
		||||
                    case "Substring":
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user