mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
MSSQL: Escape joker chars in conjunction with an "ESCAPE" appendix after the LIKE clause. See http://www.heidisql.com/forum.php?t=12747 .
This commit is contained in:
@@ -344,6 +344,7 @@ type
|
||||
procedure ParseRoutineStructure(Obj: TDBObject; Parameters: TRoutineParamList);
|
||||
function GetDatatypeByName(Datatype: String): TDBDatatype;
|
||||
function ApplyLimitClause(QueryType, QueryBody: String; Limit, Offset: Cardinal): String;
|
||||
function LikeClauseTail: String;
|
||||
property Parameters: TConnectionParameters read FParameters write FParameters;
|
||||
property ThreadId: Cardinal read GetThreadId;
|
||||
property ConnectionUptime: Integer read GetConnectionUptime;
|
||||
@@ -2264,17 +2265,16 @@ begin
|
||||
EscChar := '''';
|
||||
Result := escChars(Text, EscChar, c1, c2, c3, c4);
|
||||
|
||||
{ // TODO: escape joker chars % and _ in conjunction with a specified escape char after the WHERE clause.
|
||||
// Did not work on MSSQL 2008 here.
|
||||
// http://www.techtamasha.com/escape-single-quotes-and-wild-cards-_-in-ms-sql/20
|
||||
// Escape joker chars % and _ in conjunction with a specified escape char after the WHERE clause.
|
||||
// See http://www.heidisql.com/forum.php?t=12747
|
||||
if ProcessJokerChars then begin
|
||||
c1 := '%';
|
||||
c2 := '_';
|
||||
c4 := '_';
|
||||
c3 := '_';
|
||||
EscChar := '\';
|
||||
Result := escChars(Text, EscChar, c1, c2, c3, c4);
|
||||
end; }
|
||||
Result := escChars(Result, EscChar, c1, c2, c3, c4);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
@@ -3654,6 +3654,15 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TDBConnection.LikeClauseTail: String;
|
||||
begin
|
||||
case FParameters.NetTypeGroup of
|
||||
ngMSSQL: Result := ' ESCAPE ' + EscapeString('\');
|
||||
ngMySQL: Result := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ TMySQLQuery }
|
||||
|
||||
|
||||
@@ -5352,6 +5352,9 @@ begin
|
||||
end else
|
||||
Filter := Item.Hint;
|
||||
|
||||
if ExecRegExpr('\s+LIKE\s+''', Filter) then
|
||||
Filter := Filter + ActiveConnection.LikeClauseTail;
|
||||
|
||||
if Filter <> '' then begin
|
||||
SynMemoFilter.UndoList.AddGroupBreak;
|
||||
SynMemoFilter.SelectAll;
|
||||
@@ -7629,6 +7632,7 @@ begin
|
||||
Line := '';
|
||||
end;
|
||||
end;
|
||||
Clause := Clause + Conn.LikeClauseTail;
|
||||
end;
|
||||
SynMemoFilter.UndoList.AddGroupBreak;
|
||||
SynMemoFilter.SelectAll;
|
||||
|
||||
Reference in New Issue
Block a user