+ Samples are compilable with Delphi 10.2 Tokyo or better

This commit is contained in:
Daniele Teti 2022-03-31 09:31:11 +02:00
parent fda68ca3b9
commit 96bb67a29d
8 changed files with 63 additions and 36 deletions

View File

@ -715,6 +715,9 @@ The current beta release is named 3.2.2-nitrogen. If you want to stay on the-edg
- Fixed an `IFDEF` compatibility problem on mobile platforms (Thanks to Marco Cotroneo)
- Samples are syntax compatible with Delphi 10.1 Berlin or better (Thanks to Mark Lobanov)
## Older Releases
### What's New in 3.2.0-boron

View File

@ -771,12 +771,16 @@ begin
end;
procedure TMainForm.btnPartitioningClick(Sender: TObject);
var
lCust1: TCustomerWithRate1;
lCust2: TCustomerWithRate2;
lList: TObjectList<TCustomerWithRate1>;
begin
TMVCActiveRecord.DeleteAll(TCustomerWithRate1);
Assert(TMVCActiveRecord.Count(TCustomerWithRate1) = 0);
TMVCActiveRecord.DeleteAll(TCustomerWithRate2);
Assert(TMVCActiveRecord.Count(TCustomerWithRate2) = 0);
var lCust1 := TCustomerWithRate1.Create;
lCust1 := TCustomerWithRate1.Create;
try
lCust1.City := 'Rome';
lCust1.Code := '123';
@ -784,7 +788,7 @@ begin
finally
lCust1.Free;
end;
var lCust2 := TCustomerWithRate2.Create;
lCust2 := TCustomerWithRate2.Create;
try
lCust2.City := 'Rome';
lCust2.Code := '456';
@ -794,7 +798,7 @@ begin
lCust2.Free;
end;
var lList := TMVCActiveRecord.SelectRQL<TCustomerWithRate1>('eq(city,"Rome")',-1);
lList := TMVCActiveRecord.SelectRQL<TCustomerWithRate1>('eq(city,"Rome")',-1);
try
Assert(lList.Count = 1);
Assert(lList[0].Code = '123');
@ -1163,16 +1167,31 @@ begin
end;
procedure TMainForm.btnTableFilterClick(Sender: TObject);
var
i: Integer;
lIDOfABadCustomer: Int64;
lIDOfAGoodCustomer: Int64;
lHowMany: Int64;
lCust: TMVCActiveRecord;
Customer: TCustomer;
lCustomer: TCustomer;
lCustomer1: TCustomer;
lNotAGoodCustomer: TCustomer;
lThisShouldBeNil: TCustomer;
lAGoodCustomer: TCustomer;
lThisShouldNotBeNil: TCustomer;
lGoodCustomers: TObjectList<TGoodCustomer>;
lGoodCustomers2: TMVCActiveRecordList;
begin
Log('**Table Filtering');
Log('Deleting only best customers...');
var lIDOfABadCustomer := -1;
var lIDOfAGoodCustomer := -1;
lIDOfABadCustomer := -1;
lIDOfAGoodCustomer := -1;
TMVCActiveRecord.DeleteAll(TGoodCustomer);
Log('Inserting some customers');
for var I := 1 to 5 do
for i := 1 to 5 do
begin
var Customer := TCustomer.Create();
Customer := TCustomer.Create();
try
Customer.Code := I.ToString;
Customer.Rating := I;
@ -1191,10 +1210,10 @@ begin
end;
Log('Retrieving only best customers...');
var lGoodCustomers := TMVCActiveRecord.SelectRQL<TGoodCustomer>('sort(+rating)',10);
lGoodCustomers := TMVCActiveRecord.SelectRQL<TGoodCustomer>('sort(+rating)',10);
try
Assert(lGoodCustomers.Count = 2); { only rating >= 4}
for var lCust in lGoodCustomers do
for lCust in lGoodCustomers do
begin
Log(lCust.ToString);
end;
@ -1203,7 +1222,7 @@ begin
end;
Log('How many "best customers" we have?');
var lHowMany := TMVCActiveRecord.Count<TGoodCustomer>;
lHowMany := TMVCActiveRecord.Count<TGoodCustomer>;
Log(Format('We have %d best customers', [lHowMany]));
Log('How many "best customers" with rating = 5 we have?');
@ -1211,10 +1230,10 @@ begin
Log(Format('We have %d best customers with rating = 5', [lHowMany]));
Log('Retrieving only best customers...');
var lGoodCustomers2 := TMVCActiveRecord.SelectRQL(TGoodCustomer, '', -1);
lGoodCustomers2 := TMVCActiveRecord.SelectRQL(TGoodCustomer, '', -1);
try
Assert(lGoodCustomers2.Count = 2); { only rating >= 4}
for var lCust in lGoodCustomers2 do
for lCust in lGoodCustomers2 do
begin
Log(lCust.ToString);
end;
@ -1226,7 +1245,7 @@ begin
lGoodCustomers := TMVCActiveRecord.SelectRQL<TGoodCustomer>('sort(+CompanyName)',10);
try
Assert(lGoodCustomers.Count = 2); { only rating >= 4}
for var lCust in lGoodCustomers do
for lCust in lGoodCustomers do
begin
Log(lCust.ToString);
end;
@ -1237,17 +1256,17 @@ begin
Log('Retrieving only best customers...');
var lNotAGoodCustomer := TMVCActiveRecord.SelectOneByRQL<TCustomer>('eq(rating,1)', True);
lNotAGoodCustomer := TMVCActiveRecord.SelectOneByRQL<TCustomer>('eq(rating,1)', True);
try
var lThisShouldBeNil := TMVCActiveRecord.GetByPK<TGoodCustomer>(lNotAGoodCustomer.ID, False);
lThisShouldBeNil := TMVCActiveRecord.GetByPK<TGoodCustomer>(lNotAGoodCustomer.ID, False);
Assert(lThisShouldBeNil = nil);
finally
lNotAGoodCustomer.Free;
end;
var lAGoodCustomer := TMVCActiveRecord.SelectOneByRQL<TCustomer>('eq(rating,5)', True);
lAGoodCustomer := TMVCActiveRecord.SelectOneByRQL<TCustomer>('eq(rating,5)', True);
try
var lThisShouldNotBeNil := TMVCActiveRecord.GetByPK<TGoodCustomer>(lAGoodCustomer.ID, False);
lThisShouldNotBeNil := TMVCActiveRecord.GetByPK<TGoodCustomer>(lAGoodCustomer.ID, False);
try
Assert(lThisShouldNotBeNil <> nil);
Log(lThisShouldNotBeNil.ToString);
@ -1259,7 +1278,7 @@ begin
end;
Log('Promoting a customer...');
var lCustomer := TBadCustomer.Create;
lCustomer := TBadCustomer.Create;
try
lCustomer.LoadByPK(lIDOfABadCustomer);
lCustomer.Rating := 5;
@ -1270,7 +1289,7 @@ begin
end;
Log('Demote a customer...');
var lCustomer1 := TGoodCustomer.Create;
lCustomer1 := TGoodCustomer.Create;
try
lCustomer1.LoadByPK(lIDOfAGoodCustomer);
lCustomer1.Rating := 1;

View File

@ -164,7 +164,7 @@ end;
procedure TMainForm.btnExceptionClick(Sender: TObject);
var
lReq: IJSONRPCNotification;
lResp: IJSONRPCResponse;
// lResp: IJSONRPCResponse;
begin
ShowMessage('Now will be raised a custom exception on the server. This exception will be catched by the client');
lReq := TJSONRPCNotification.Create('RaiseCustomException');

View File

@ -152,9 +152,11 @@ begin
end;
procedure TOrder.OnAfterInsert;
var
lOrderDetail: TOrderDetail;
begin
inherited;
for var lOrderDetail in fDetails do
for lOrderDetail in fDetails do
begin
lOrderDetail.IDOrder := ID;
lOrderDetail.Insert;
@ -162,9 +164,11 @@ begin
end;
procedure TOrder.OnAfterUpdate;
var
lOrderItems: TObjectList<TOrderDetail>;
begin
inherited;
var lOrderItems := TMVCActiveRecord.SelectRQL<TOrderDetail>(Format('eq(idorder,%d)', [ID]), 100);
lOrderItems := TMVCActiveRecord.SelectRQL<TOrderDetail>(Format('eq(idorder,%d)', [ID]), 100);
try
TMVCActiveRecord.Merge<TOrderDetail>(lOrderItems, fDetails)
.Apply(

View File

@ -121,7 +121,6 @@ begin
end;
procedure TOrdersController.GetOrdersByDescription(const Search: String);
var
lDict: IMVCObjectDictionary;
begin
// Render(
@ -149,9 +148,11 @@ begin
end;
procedure TOrdersController.UpdateOrderByID(const Order: TOrder; const id: Integer);
var
lCurrentOrder: TOrder;
begin
Order.id := id;
var lCurrentOrder := TMVCActiveRecord.GetByPK<TOrder>(id);
lCurrentOrder := TMVCActiveRecord.GetByPK<TOrder>(id);
try
Order.Update();
finally

View File

@ -67,8 +67,10 @@ begin
end;
procedure TMyController.CreateCustomer;
var
lCustomer: TCustomer;
begin
var lCustomer := Self.Context.Request.BodyAs<TCustomer>;
lCustomer := Self.Context.Request.BodyAs<TCustomer>;
try
if not lCustomer.IsValid then
begin
@ -82,8 +84,10 @@ begin
end;
procedure TMyController.UpdateCustomer(id: Integer);
var
lCustomer: TCustomer;
begin
var lCustomer := Self.Context.Request.BodyAs<TCustomer>;
lCustomer := Self.Context.Request.BodyAs<TCustomer>;
try
lCustomer.ID := id; //dont be confident of the user!
if not lCustomer.IsValid then

View File

@ -81,7 +81,9 @@ type
AAuthData: String; var VUsername, VPassword: String;
var VHandled: Boolean);
procedure OnGetSSLPassword(var APassword: string);
{$IF Defined(RIOORBETTER)}
procedure QuerySSLPort(APort: Word; var VUseSSL: boolean);
{$ENDIF}
protected
function GetActive: Boolean;
@ -265,7 +267,7 @@ begin
FBridgeSSLHandler.SSLOptions.KeyFile := lSSLKeyFile;
FBridgeSSLHandler.OnGetPassword := OnGetSSLPassword;
FBridge.IOHandler := FBridgeSSLHandler;
{$IF CompilerVersion >= 33}
{$IF Defined(RIOORBETTER)}
FBridge.OnQuerySSLPort := QuerySSLPort;
{$ENDIF}
end;
@ -288,10 +290,13 @@ begin
vhandled := True;
end;
{$IF Defined(RIOORBETTER)}
procedure TMVCListener.QuerySSLPort(APort: Word; var VUseSSL: boolean);
begin
VUseSSL := true;
end;
{$ENDIF}
function TMVCListener.GetActive: Boolean;
begin

View File

@ -449,12 +449,3 @@ def generate_nullables(ctx):
with open(src_folder.joinpath("implementation.out.txt"), "w") as f:
f.writelines(impl_tmpl)
@task()
def pippo(ctx):
r = ctx.run("cmd.exe /c dsir", hide=True, warn=True)
if r.failed:
print(r.stderr)
else:
print(r.stdout)