Merge pull request #328 from joaoduarte19/rql_bugfix

Rql bugfix
This commit is contained in:
Daniele Teti 2020-02-22 16:51:29 +01:00 committed by GitHub
commit c919faa1e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 168 additions and 20 deletions

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{FD44EB2E-3630-4DA7-A18A-D8F572433F4E}</ProjectGuid>
<ProjectVersion>18.7</ProjectVersion>
<ProjectVersion>18.8</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>RQL2SQL.dpr</MainSource>
<Base>True</Base>
@ -165,12 +165,20 @@
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider">
<Platform Name="Android">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
@ -183,138 +191,242 @@
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiv7aFile">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeMipsFile">
<Platform Name="Android">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashImageDef">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStyles">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStylesV21">
<Platform Name="Android">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Colors">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_DefaultAppIcon">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon144">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon24">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage426">
<Platform Name="Android">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage470">
<Platform Name="Android">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage640">
<Platform Name="Android">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage960">
<Platform Name="Android">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Strings">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DebugSymbols">
<Platform Name="iOSSimulator">
@ -403,6 +515,9 @@
<Platform Name="Android">
<Operation>0</Operation>
</Platform>
<Platform Name="Android64">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>0</Operation>
</Platform>
@ -736,6 +851,9 @@
<Platform Name="Android">
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
@ -828,6 +946,10 @@
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
@ -852,6 +974,12 @@
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectUWPManifest">
<Platform Name="Win32">
<Operation>1</Operation>
@ -889,6 +1017,7 @@
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Win32">True</Platform>

View File

@ -1,3 +1,5 @@
and(eq(nome,"Marca d'água"), contains(nome,"Marca d'água"), in(nome, ["Marca", "D'água"]))
and(eq(nome,"Marca d'água"), contains(nome,"Marca d'água"))
ne(value,null)
eq(value,null)
eq(value,false)

View File

@ -128,7 +128,7 @@ begin
end;
tkContains:
begin
Result := Format('(%s containing ''%s'')', [lDBFieldName, lValue.DeQuotedString.ToLower])
Result := Format('(%s containing %s)', [lDBFieldName, lValue.ToLower])
end;
tkIn:
begin
@ -141,8 +141,8 @@ begin
end;
vtStringArray:
begin
Result := Format('(%s IN (''%s''))', [
lDBFieldName, string.Join(''',''', aRQLFIlter.OpRightArray)
Result := Format('(%s IN (%s))', [
lDBFieldName, string.Join(',', QuoteStringArray(aRQLFIlter.OpRightArray))
]);
end;
else

View File

@ -89,7 +89,7 @@ function TRQLMSSQLCompiler.RQLFilterToSQL(const aRQLFIlter: TRQLFilter): string;
var
lValue, lDBFieldName: string;
begin
if aRQLFIlter.RightValueType = vtString then
if (aRQLFIlter.RightValueType = vtString) and (aRQLFIlter.Token <> tkContains) then
lValue := aRQLFIlter.OpRight.QuotedString('''')
else if aRQLFIlter.RightValueType = vtBoolean then
begin
@ -136,7 +136,8 @@ begin
end;
tkContains:
begin
Result := Format('(LOWER(%s) LIKE ''%%%s%%'')', [lDBFieldName, lValue.DeQuotedString.ToLower])
lValue := Format('%%%s%%', [lValue]).QuotedString('''');
Result := Format('(LOWER(%s) LIKE %s)', [lDBFieldName, lValue.ToLower])
end;
tkIn:
begin
@ -149,8 +150,8 @@ begin
end;
vtStringArray:
begin
Result := Format('(%s IN (''%s''))', [
lDBFieldName, string.Join(''',''', aRQLFIlter.OpRightArray)
Result := Format('(%s IN (%s))', [
lDBFieldName, string.Join(',', QuoteStringArray(aRQLFIlter.OpRightArray))
]);
end;
else

View File

@ -80,7 +80,7 @@ function TRQLMySQLCompiler.RQLFilterToSQL(const aRQLFIlter: TRQLFilter): string;
var
lValue, lDBFieldName: string;
begin
if aRQLFIlter.RightValueType = vtString then
if (aRQLFIlter.RightValueType = vtString) and (aRQLFIlter.Token <> tkContains) then
lValue := aRQLFIlter.OpRight.QuotedString('''')
else if aRQLFIlter.RightValueType = vtBoolean then
begin
@ -127,7 +127,8 @@ begin
end;
tkContains:
begin
Result := Format('(LOWER(%s) LIKE ''%%%s%%'')', [lDBFieldName, lValue.DeQuotedString.ToLower])
lValue := Format('%%%s%%', [lValue]).QuotedString('''');
Result := Format('(LOWER(%s) LIKE %s)', [lDBFieldName, lValue.ToLower])
end;
tkIn:
begin
@ -140,8 +141,8 @@ begin
end;
vtStringArray:
begin
Result := Format('(%s IN (''%s''))', [
lDBFieldName, string.Join(''',''', aRQLFIlter.OpRightArray)
Result := Format('(%s IN (%s))', [
lDBFieldName, string.Join(',', QuoteStringArray(aRQLFIlter.OpRightArray))
]);
end;
else

View File

@ -81,7 +81,7 @@ function TRQLPostgreSQLCompiler.RQLFilterToSQL(const aRQLFIlter: TRQLFilter): st
var
lValue, lDBFieldName: string;
begin
if aRQLFIlter.RightValueType = vtString then
if (aRQLFIlter.RightValueType = vtString) and (aRQLFIlter.Token <> tkContains) then
lValue := aRQLFIlter.OpRight.QuotedString('''')
else
lValue := aRQLFIlter.OpRight;
@ -121,7 +121,8 @@ begin
end;
tkContains:
begin
Result := Format('(%s ILIKE ''%%%s%%'')', [lDBFieldName, lValue.DeQuotedString.ToLower])
lValue := Format('%%%s%%', [lValue]).QuotedString('''');
Result := Format('(%s ILIKE %s)', [lDBFieldName, lValue.ToLower])
end;
tkIn:
begin
@ -134,8 +135,8 @@ begin
end;
vtStringArray:
begin
Result := Format('(%s IN (''%s''))', [
lDBFieldName, string.Join(''',''', aRQLFIlter.OpRightArray)
Result := Format('(%s IN (%s))', [
lDBFieldName, string.Join(',', QuoteStringArray(aRQLFIlter.OpRightArray))
]);
end;
else

View File

@ -82,7 +82,7 @@ function TRQLSQLiteCompiler.RQLFilterToSQL(const aRQLFIlter: TRQLFilter): string
var
lValue, lDBFieldName: string;
begin
if aRQLFIlter.RightValueType = vtString then
if (aRQLFIlter.RightValueType = vtString) and (aRQLFIlter.Token <> tkContains) then
lValue := aRQLFIlter.OpRight.QuotedString('''')
else
lValue := aRQLFIlter.OpRight;
@ -122,7 +122,8 @@ begin
end;
tkContains:
begin
Result := Format('(%s LIKE ''%%%s%%'')', [lDBFieldName, lValue.DeQuotedString.ToLower])
lValue := Format('%%%s%%', [lValue]).QuotedString('''');
Result := Format('(%s LIKE %s)', [lDBFieldName, lValue.ToLower])
end;
tkIn:
begin
@ -135,8 +136,8 @@ begin
end;
vtStringArray:
begin
Result := Format('(%s IN (''%s''))', [
lDBFieldName, string.Join(''',''', aRQLFIlter.OpRightArray)
Result := Format('(%s IN (%s))', [
lDBFieldName, string.Join(',', QuoteStringArray(aRQLFIlter.OpRightArray))
]);
end;
else

View File

@ -93,6 +93,7 @@ type
fMapping: TMVCFieldsMapping;
protected
function GetDatabaseFieldName(const RQLPropertyName: string): string;
function QuoteStringArray(const aStringArray: TArray<string>): TArray<string>;
public
constructor Create(const Mapping: TMVCFieldsMapping); virtual;
procedure AST2SQL(const aRQLAST: TRQLAbstractSyntaxTree; out aSQL: string); virtual; abstract;
@ -1152,6 +1153,18 @@ begin
[RQLPropertyName]);
end;
function TRQLCompiler.QuoteStringArray(const aStringArray: TArray<string>): TArray<string>;
var
lValue: string;
begin
SetLength(Result, 0);
for lValue in aStringArray do
begin
SetLength(Result, Length(Result) + 1);
Result[High(Result)] := lValue.QuotedString('''');
end;
end;
{ TRQLAbstractSyntaxTree }
constructor TRQLAbstractSyntaxTree.Create;