mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
Merge pull request #235 from joaoduarte19/rql_changes
Added support for comparisons with null fields
This commit is contained in:
commit
4b41c65721
@ -98,6 +98,9 @@ begin
|
||||
case aRQLFIlter.Token of
|
||||
tkEq:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s = %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkLt:
|
||||
@ -118,6 +121,9 @@ begin
|
||||
end;
|
||||
tkNe:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NOT NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s != %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkContains:
|
||||
|
@ -106,6 +106,9 @@ begin
|
||||
case aRQLFIlter.Token of
|
||||
tkEq:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s = %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkLt:
|
||||
@ -126,6 +129,9 @@ begin
|
||||
end;
|
||||
tkNe:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NOT NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s != %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkContains:
|
||||
|
@ -97,6 +97,9 @@ begin
|
||||
case aRQLFIlter.Token of
|
||||
tkEq:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s = %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkLt:
|
||||
@ -117,6 +120,9 @@ begin
|
||||
end;
|
||||
tkNe:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NOT NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s != %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkContains:
|
||||
|
@ -91,6 +91,9 @@ begin
|
||||
case aRQLFIlter.Token of
|
||||
tkEq:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s = %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkLt:
|
||||
@ -111,6 +114,9 @@ begin
|
||||
end;
|
||||
tkNe:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NOT NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s != %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkContains:
|
||||
|
@ -92,6 +92,9 @@ begin
|
||||
case aRQLFIlter.Token of
|
||||
tkEq:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s = %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkLt:
|
||||
@ -112,6 +115,9 @@ begin
|
||||
end;
|
||||
tkNe:
|
||||
begin
|
||||
if aRQLFIlter.RightValueType = vtNull then
|
||||
Result := Format('(%s IS NOT NULL)', [lDBFieldName])
|
||||
else
|
||||
Result := Format('(%s != %s)', [lDBFieldName, lValue]);
|
||||
end;
|
||||
tkContains:
|
||||
|
@ -78,7 +78,7 @@ type
|
||||
tkOpenPar, tkClosedPar, tkOpenBracket, tkCloseBracket, tkComma, tkSemicolon, tkPlus, tkMinus, tkDblQuote,
|
||||
tkQuote, tkSpace, tkContains, tkIn, tkUnknown);
|
||||
|
||||
TRQLValueType = (vtInteger, vtString, vtBoolean, vtIntegerArray, vtStringArray);
|
||||
TRQLValueType = (vtInteger, vtString, vtBoolean, vtNull, vtIntegerArray, vtStringArray);
|
||||
|
||||
TRQLCustom = class;
|
||||
|
||||
@ -188,6 +188,7 @@ type
|
||||
function MatchFieldNumericValue(out lFieldValue: string): Boolean;
|
||||
function MatchFieldArrayValue(out lFieldValue: string): Boolean;
|
||||
function MatchFieldBooleanValue(out lFieldValue: string): Boolean;
|
||||
function MatchFieldNullValue(out lFieldValue: string): Boolean;
|
||||
function MatchSymbol(const Symbol: Char): Boolean;
|
||||
procedure SaveCurPos;
|
||||
procedure BackToLastPos;
|
||||
@ -618,10 +619,12 @@ begin
|
||||
|
||||
if MatchFieldBooleanValue(lFieldValue) then
|
||||
lValueType := vtBoolean
|
||||
else if MatchFieldNullValue(LFieldValue) then
|
||||
lValueType := vtNull
|
||||
else if MatchFieldNumericValue(lFieldValue) then
|
||||
lValueType := vtInteger
|
||||
else
|
||||
Error('Expected numeric or boolean value');
|
||||
Error('Expected numeric, boolean or null value');
|
||||
end;
|
||||
EatWhiteSpaces;
|
||||
if GetToken <> tkClosedPar then
|
||||
@ -911,6 +914,23 @@ begin
|
||||
Exit(False);
|
||||
end;
|
||||
|
||||
function TRQL2SQL.MatchFieldNullValue(out lFieldValue: string): Boolean;
|
||||
var
|
||||
lChar: Char;
|
||||
begin
|
||||
lFieldValue := '';
|
||||
lChar := C(0).ToLower;
|
||||
|
||||
if (lChar = 'n') and (C(1).ToLower = 'u') and (C(2).ToLower = 'l') and (C(3).ToLower = 'l') then
|
||||
begin
|
||||
Skip(4);
|
||||
Result := True;
|
||||
lFieldValue := 'NULL';
|
||||
end
|
||||
else
|
||||
Exit(False)
|
||||
end;
|
||||
|
||||
function TRQL2SQL.MatchFieldNumericValue(out lFieldValue: string): Boolean;
|
||||
var
|
||||
lChar: Char;
|
||||
|
@ -1,3 +1,5 @@
|
||||
ne(value,null)
|
||||
eq(value,null)
|
||||
eq(value,false)
|
||||
eq(value,true)
|
||||
in ( value , [ 1 , 2 , 3 ] )
|
||||
|
Loading…
Reference in New Issue
Block a user