mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 优化 ClickHouse like 为 positionCaseInsensitive #1386
This commit is contained in:
parent
f415ca7765
commit
7a64f9d65f
@ -317,16 +317,9 @@ namespace FreeSql.ClickHouse
|
|||||||
case "Contains":
|
case "Contains":
|
||||||
var args0Value = getExp(exp.Arguments[0]);
|
var args0Value = getExp(exp.Arguments[0]);
|
||||||
if (args0Value == "NULL") return $"({left}) IS NULL";
|
if (args0Value == "NULL") return $"({left}) IS NULL";
|
||||||
if (args0Value.Contains("%"))
|
if (exp.Method.Name == "StartsWith") return $"positionCaseInsensitive({left}, {args0Value}) = 1";
|
||||||
{
|
|
||||||
if (exp.Method.Name == "StartsWith") return $"locate({args0Value}, {left}) = 1";
|
|
||||||
if (exp.Method.Name == "EndsWith") return $"locate({args0Value}, {left}) = char_length({args0Value})";
|
|
||||||
return $"locate({args0Value}, {left}) > 0";
|
|
||||||
}
|
|
||||||
if (exp.Method.Name == "StartsWith") return $"({left}) LIKE {(args0Value.EndsWith("'") ? args0Value.Insert(args0Value.Length - 1, "%") : $"concat({args0Value}, '%')")}";
|
|
||||||
if (exp.Method.Name == "EndsWith") return $"({left}) LIKE {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"concat('%', {args0Value})")}";
|
if (exp.Method.Name == "EndsWith") return $"({left}) LIKE {(args0Value.StartsWith("'") ? args0Value.Insert(1, "%") : $"concat('%', {args0Value})")}";
|
||||||
if (args0Value.StartsWith("'") && args0Value.EndsWith("'")) return $"({left}) LIKE {args0Value.Insert(1, "%").Insert(args0Value.Length, "%")}";
|
return $"positionCaseInsensitive({left}, {args0Value}) > 0";
|
||||||
return $"({left}) LIKE concat('%', {args0Value}, '%')";
|
|
||||||
case "ToLower": return $"lower({left})";
|
case "ToLower": return $"lower({left})";
|
||||||
case "ToUpper": return $"upper({left})";
|
case "ToUpper": return $"upper({left})";
|
||||||
case "Substring":
|
case "Substring":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user