mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
Merge pull request #228 from joaoduarte19/rql_changes
Added Boolean type support in RQLParser
This commit is contained in:
commit
f78953c83f
@ -83,6 +83,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if aRQLFIlter.RightValueType = vtString then
|
if aRQLFIlter.RightValueType = vtString then
|
||||||
lValue := aRQLFIlter.OpRight.QuotedString('''')
|
lValue := aRQLFIlter.OpRight.QuotedString('''')
|
||||||
|
else if aRQLFIlter.RightValueType = vtBoolean then
|
||||||
|
begin
|
||||||
|
if SameText(aRQLFIlter.OpRight, 'true') then
|
||||||
|
lValue := '1'
|
||||||
|
else
|
||||||
|
lValue := '0';
|
||||||
|
end
|
||||||
else
|
else
|
||||||
lValue := aRQLFIlter.OpRight;
|
lValue := aRQLFIlter.OpRight;
|
||||||
|
|
||||||
|
@ -91,6 +91,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if aRQLFIlter.RightValueType = vtString then
|
if aRQLFIlter.RightValueType = vtString then
|
||||||
lValue := aRQLFIlter.OpRight.QuotedString('''')
|
lValue := aRQLFIlter.OpRight.QuotedString('''')
|
||||||
|
else if aRQLFIlter.RightValueType = vtBoolean then
|
||||||
|
begin
|
||||||
|
if SameText(aRQLFIlter.OpRight, 'true') then
|
||||||
|
lValue := '1'
|
||||||
|
else
|
||||||
|
lValue := '0';
|
||||||
|
end
|
||||||
else
|
else
|
||||||
lValue := aRQLFIlter.OpRight;
|
lValue := aRQLFIlter.OpRight;
|
||||||
|
|
||||||
|
@ -82,6 +82,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if aRQLFIlter.RightValueType = vtString then
|
if aRQLFIlter.RightValueType = vtString then
|
||||||
lValue := aRQLFIlter.OpRight.QuotedString('''')
|
lValue := aRQLFIlter.OpRight.QuotedString('''')
|
||||||
|
else if aRQLFIlter.RightValueType = vtBoolean then
|
||||||
|
begin
|
||||||
|
if SameText(aRQLFIlter.OpRight, 'true') then
|
||||||
|
lValue := '1'
|
||||||
|
else
|
||||||
|
lValue := '0';
|
||||||
|
end
|
||||||
else
|
else
|
||||||
lValue := aRQLFIlter.OpRight;
|
lValue := aRQLFIlter.OpRight;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ type
|
|||||||
tkOpenPar, tkClosedPar, tkOpenBracket, tkCloseBracket, tkComma, tkSemicolon, tkPlus, tkMinus, tkDblQuote,
|
tkOpenPar, tkClosedPar, tkOpenBracket, tkCloseBracket, tkComma, tkSemicolon, tkPlus, tkMinus, tkDblQuote,
|
||||||
tkQuote, tkSpace, tkContains, tkIn, tkUnknown);
|
tkQuote, tkSpace, tkContains, tkIn, tkUnknown);
|
||||||
|
|
||||||
TRQLValueType = (vtInteger, vtString, vtIntegerArray, vtStringArray);
|
TRQLValueType = (vtInteger, vtString, vtBoolean, vtIntegerArray, vtStringArray);
|
||||||
|
|
||||||
TRQLCustom = class;
|
TRQLCustom = class;
|
||||||
|
|
||||||
@ -187,6 +187,7 @@ type
|
|||||||
function MatchFieldStringValue(out lFieldValue: string): Boolean;
|
function MatchFieldStringValue(out lFieldValue: string): Boolean;
|
||||||
function MatchFieldNumericValue(out lFieldValue: string): Boolean;
|
function MatchFieldNumericValue(out lFieldValue: string): Boolean;
|
||||||
function MatchFieldArrayValue(out lFieldValue: string): Boolean;
|
function MatchFieldArrayValue(out lFieldValue: string): Boolean;
|
||||||
|
function MatchFieldBooleanValue(out lFieldValue: string): Boolean;
|
||||||
function MatchSymbol(const Symbol: Char): Boolean;
|
function MatchSymbol(const Symbol: Char): Boolean;
|
||||||
procedure SaveCurPos;
|
procedure SaveCurPos;
|
||||||
procedure BackToLastPos;
|
procedure BackToLastPos;
|
||||||
@ -613,9 +614,13 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
BackToLastPos;
|
BackToLastPos;
|
||||||
if not MatchFieldNumericValue(lFieldValue) then
|
|
||||||
Error('Expected numeric value');
|
if MatchFieldBooleanValue(lFieldValue) then
|
||||||
lValueType := vtInteger;
|
lValueType := vtBoolean
|
||||||
|
else if MatchFieldNumericValue(lFieldValue) then
|
||||||
|
lValueType := vtInteger
|
||||||
|
else
|
||||||
|
Error('Expected numeric or boolean value');
|
||||||
end;
|
end;
|
||||||
EatWhiteSpaces;
|
EatWhiteSpaces;
|
||||||
if GetToken <> tkClosedPar then
|
if GetToken <> tkClosedPar then
|
||||||
@ -857,6 +862,30 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRQL2SQL.MatchFieldBooleanValue(out lFieldValue: string): Boolean;
|
||||||
|
var
|
||||||
|
lChar: Char;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
lFieldValue := '';
|
||||||
|
lChar := C(0).ToLower;
|
||||||
|
|
||||||
|
if (lChar = 't') and (C(1).ToLower = 'r') and (C(2).ToLower = 'u') and (C(3).ToLower = 'e') then
|
||||||
|
begin
|
||||||
|
Skip(4);
|
||||||
|
Result := True;
|
||||||
|
lFieldValue := 'true';
|
||||||
|
end
|
||||||
|
else if (lChar = 'f') and (C(1).ToLower = 'a') and (C(2).ToLower = 'l') and (C(3).ToLower = 's') and (C(4).ToLower = 'e') then
|
||||||
|
begin
|
||||||
|
Skip(5);
|
||||||
|
Result := True;
|
||||||
|
lFieldValue := 'false';
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Exit(False)
|
||||||
|
end;
|
||||||
|
|
||||||
function TRQL2SQL.MatchFieldName(out lFieldName: string): Boolean;
|
function TRQL2SQL.MatchFieldName(out lFieldName: string): Boolean;
|
||||||
var
|
var
|
||||||
lChar: Char;
|
lChar: Char;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
eq(value,false)
|
||||||
|
eq(value,true)
|
||||||
in ( value , [ 1 , 2 , 3 ] )
|
in ( value , [ 1 , 2 , 3 ] )
|
||||||
in ( value , [ 1 , 2 , 3 ] )
|
in ( value , [ 1 , 2 , 3 ] )
|
||||||
in(value,[])
|
in(value,[])
|
||||||
|
Loading…
Reference in New Issue
Block a user