Skip to content

Commit b3cf74e

Browse files
committed
For inMem SQLLike implementation.#27
1 parent c7707b0 commit b3cf74e

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

Source/BoldOclSymbolImplementations.pas

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,7 +2990,7 @@ procedure TBOS_Attributes.Evaluate(const Params: TBoldOclSymbolParameters);
29902990
begin
29912991
ClassInfo := Params.values[0] as TBoldClassTypeInfo;
29922992
Name := help.CreateNewMember(Help.StringType) as TBAString;
2993-
for i := 0 to ClassInfo.AllMembers.Count - 1 do
2993+
for i := 0 to ClassInfo.AllMembersCount - 1 do
29942994
begin
29952995
MemberRTInfo := ClassInfo.AllMembers[i];
29962996
if MemberRTInfo.IsAttribute then
@@ -3016,7 +3016,7 @@ procedure TBOS_AssociationEnds.Evaluate(const Params: TBoldOclSymbolParameters);
30163016
begin
30173017
ClassInfo := Params.values[0] as TBoldClassTypeInfo;
30183018
Name := help.CreateNewMember(Help.StringType) as TBAString;
3019-
for i := 0 to ClassInfo.AllMembers.Count - 1 do
3019+
for i := 0 to ClassInfo.AllMembersCount - 1 do
30203020
begin
30213021
MemberRTInfo := ClassInfo.AllMembers[i];
30223022
if MemberRTInfo.IsRole then
@@ -3110,10 +3110,38 @@ procedure TBOS_AllSubClasses.Evaluate(const Params: TBoldOclSymbolParameters);
31103110
end;
31113111
end;
31123112

3113+
function SQLLikeToRegEx(const AExpression: string): string;
3114+
var
3115+
l: integer;
3116+
Starts, Ends: boolean;
3117+
begin
3118+
l := Length(AExpression);
3119+
if l > 1 then
3120+
begin
3121+
Starts := Copy(AExpression, 1, 1) = '%';
3122+
Ends := Copy(AExpression, l, 1) = '%';
3123+
if Starts and Ends then
3124+
result := '^.*' + Copy(AExpression, 2, l-2) + '.*$'
3125+
else
3126+
if Starts then
3127+
result := '^.*' + Copy(AExpression, 2, MaxInt) + '$'
3128+
else
3129+
if Ends then
3130+
result := '^' + Copy(AExpression, 1, l-1) + '.*$'
3131+
else
3132+
result := '^' + Copy(AExpression, 1, l) + '$'
3133+
end
3134+
else
3135+
if AExpression = '%' then
3136+
result := '.*'
3137+
else
3138+
result := '^' + AExpression + '$'
3139+
end;
3140+
31133141
function EscapeRegEx(const ASource: string): string;
31143142
begin
3115-
result := StringReplace(ASource, '%', '', [rfReplaceAll]);
3116-
result := TPerlRegEx.EscapeRegExChars(result);
3143+
result := TPerlRegEx.EscapeRegExChars(ASource);
3144+
result := SQLLikeToRegEx(result);
31173145
end;
31183146

31193147
procedure TBOS_SQLLike.Evaluate(const Params: TBoldOclSymbolParameters);
@@ -4076,4 +4104,4 @@ initialization
40764104
finalization
40774105
FreeAndNil(G_OCLOperations);
40784106

4079-
end.
4107+
end.

0 commit comments

Comments
 (0)