Skip to content

Commit

Permalink
3.2.0-boron-RC4
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Feb 5, 2020
1 parent 4a78322 commit c36cd13
Show file tree
Hide file tree
Showing 22 changed files with 766 additions and 2,047 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Congratulations to Daniele Teti and all the staff for the excellent work!" -- Ma
> WARNING! Considering the huge amount of features added in 3.1.1-beryllium during its RC phase, the dmvcframework-3.1.1-beryllium has been renamed to dmvcframework-3.2.0-boron
- New! Added Nullable support in MVCActiveRecord! Check *activerecord_showcase* sample.
- New! Complete support for nullable types in the default serializer.
- New! Added Swagger support (thanks to [João Antônio Duarte](https://github.com/joaoduarte19) and [Geoffrey Smith](https://github.com/geoffsmith82))
- New! Added SQLGenerator and RQL compiler for PostgreSQL, SQLite and MSSQLServer (in addition to MySQL, MariaDB, Firebird and Interbase)
- New! Added support for interfaces serialization - now it is possible to serialize Spring4D collections (thanks to [João Antônio Duarte](https://github.com/joaoduarte19))
Expand Down Expand Up @@ -139,6 +140,7 @@ Render(lPerson, False,
- New! `TMVCAnalyticsMiddleware` to do automatic analytics on the API (generates a CSV file). Based on an idea by Nirav Kaku (https://www.facebook.com/nirav.kaku). Check the sample in `\samples\middleware_analytics\`
- New! `TMVCActiveRecord.DeleteAll` deletes all the records from a table
- New! `TMVCActiveRecord.DeleteRQL` deletes records using an `RQL` expression as `where` clause.
- New! `TMVCActiveRecord.Store` which automatically executes Insert or Update considering primary key value.
- New! Microsoft SQLServer Support in `MVCActiveRecord` and RQL (*thanks to one of the biggest Delphi based company in Italy which heavily uses DMVCFramework* and *[DMSContainer](http://www.bittimeprofessionals.it/prodotti/dmscontainer)*)
- New! SQLite support in `MVCActiveRecord` and RQL, so that `MVCActiveRecord` can be used also for Delphi mobile projects!
- Default JSON Serializer can verbatim pass properties with type `JsonDataObjects.TJSONObject` without using `string` as carrier of JSON
Expand Down
4 changes: 2 additions & 2 deletions samples/activerecord_crud/EntitiesProcessors.pas
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ procedure TContactProcessor.GetEntity(const Context: TWebContext;
begin
// You can write your own entity which already load relations
// The following is the manual approach
lContact := TContact.GetByPK<TContact>(id);
lContact := TMVCActiveRecord.GetByPK<TContact>(id);
try
lPhones := TPhone.Where<TPhone>('id_person = ?', [id]);
lPhones := TMVCActiveRecord.Where<TPhone>('id_person = ?', [id]);
try
lSer := TMVCJsonDataObjectsSerializer.Create;
try
Expand Down
1 change: 0 additions & 1 deletion samples/activerecord_crud/activerecord_crud.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ uses
FireDAC.Phys.MySQL,
FireDAC.Phys.SQLite,
System.SysUtils,
MVCFramework.Logger,
MVCFramework.Commons,
MVCFramework.REPLCommandsHandlerU,
Web.ReqMulti,
Expand Down
899 changes: 131 additions & 768 deletions samples/activerecord_crud/activerecord_crud.dproj

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions samples/activerecord_showcase/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ procedure TMainForm.btnSelectClick(Sender: TObject);
lCustomers: TObjectList<TCustomer>;
lCustomer: TCustomer;
lDS: TDataSet;
lID: NullableInt64;
begin
Log('** Query SQL');
// Bypassing the RQL parser you can use DBMS-specific features or just joining your tables.
Expand Down Expand Up @@ -551,6 +552,23 @@ procedure TMainForm.btnSelectClick(Sender: TObject);
lDS.Free;
end;

Log('** GetFirstByWhere');
lCustomer := TMVCActiveRecord.GetFirstByWhere<TCustomer>('id > ?', [1]);
try
Log(Format('%8.5s - %s', [lCustomer.Code.ValueOrDefault, lCustomer.CompanyName.ValueOrDefault]));
lID := lCustomer.ID;
finally
lCustomer.Free;
end;

Log('** GetOneByWhere');
lCustomer := TMVCActiveRecord.GetOneByWhere<TCustomer>('id = ?', [lID.Value]);
try
Log(Format('%8.5s - %s', [lCustomer.Code.ValueOrDefault, lCustomer.CompanyName.ValueOrDefault]));
finally
lCustomer.Free;
end;

end;

procedure TMainForm.btnTransientFieldsClick(Sender: TObject);
Expand Down
10 changes: 5 additions & 5 deletions samples/articles_crud_server/BusinessObjects.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
interface

uses
MVCFramework.Serializer.Commons;
MVCFramework.Serializer.Commons, MVCFramework.Nullables;

type
TBaseBO = class
Expand All @@ -22,9 +22,9 @@ TArticle = class(TBaseBO)
private
FPrice: Currency;
FCode: string;
FDescription: string;
FDescription: String;
procedure SetCode(const Value: string);
procedure SetDescription(const Value: string);
procedure SetDescription(const Value: String);
procedure SetPrice(const Value: Currency);
public
procedure CheckInsert; override;
Expand All @@ -33,7 +33,7 @@ TArticle = class(TBaseBO)
[MVCColumn('CODICE')]
property Code: string read FCode write SetCode;
[MVCColumn('DESCRIZIONE')]
property Description: string read FDescription write SetDescription;
property Description: String read FDescription write SetDescription;
[MVCColumn('PREZZO')]
property Price: Currency read FPrice write SetPrice;
end;
Expand Down Expand Up @@ -94,7 +94,7 @@ procedure TArticle.SetCode(const Value: string);
FCode := Value;
end;

procedure TArticle.SetDescription(const Value: string);
procedure TArticle.SetDescription(const Value: String);
begin
FDescription := Value;
end;
Expand Down
3 changes: 2 additions & 1 deletion samples/articles_crud_server/articles_crud.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ uses
Services in 'Services.pas',
BusinessObjects in 'BusinessObjects.pas',
MainDM in 'MainDM.pas' {dmMain: TDataModule},
Commons in 'Commons.pas';
Commons in 'Commons.pas',
MVCFramework.ActiveRecord in '..\..\sources\MVCFramework.ActiveRecord.pas';

{$R *.res}

Expand Down
1 change: 1 addition & 0 deletions samples/articles_crud_server/articles_crud.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<DCCReference Include="Commons.pas"/>
<DCCReference Include="..\..\sources\MVCFramework.ActiveRecord.pas"/>
<None Include="ModelSupport_ordersmanager\default.txvpck"/>
<None Include="ModelSupport_ordersmanager\Services\default.txvpck"/>
<None Include="ModelSupport_ordersmanager\ordersmanager\default.txvpck"/>
Expand Down
30 changes: 16 additions & 14 deletions samples/articles_crud_vcl_client/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ TMainForm = class(TForm)
procedure dsArticlesBeforeRowRequest(DataSet: TFDDataSet);
procedure btnRefreshRecordClick(Sender: TObject);
private
FLoading: Boolean;
Clt: TRESTClient;
fLoading: Boolean;
fRESTClient: TRESTClient;
{ Private declarations }
procedure ShowError(const AResponse: IRESTResponse);
end;
Expand Down Expand Up @@ -72,7 +72,7 @@ procedure TMainForm.dsArticlesAfterOpen(DataSet: TDataSet);
Res: IRESTResponse;
begin
// this a simple sychronous request...
Res := Clt.doGET('/articles', []);
Res := fRESTClient.doGET('/articles', []);
if Res.HasError then
begin
ShowError(Res);
Expand All @@ -81,9 +81,9 @@ procedure TMainForm.dsArticlesAfterOpen(DataSet: TDataSet);

DataSet.DisableControls;
try
FLoading := true;
fLoading := true;
dsArticles.LoadFromJSONArrayString(Res.BodyAsString);
FLoading := false;
fLoading := false;
dsArticles.First;
finally
DataSet.EnableControls;
Expand All @@ -95,7 +95,7 @@ procedure TMainForm.dsArticlesBeforeDelete(DataSet: TDataSet);
Res: IRESTResponse;
begin
if dsArticles.State = dsBrowse then
Res := Clt.DataSetDelete('/articles', dsArticlesid.AsString);
Res := fRESTClient.DataSetDelete('/articles', dsArticlesid.AsString);
if not(Res.ResponseCode in [200]) then
begin
ShowError(Res);
Expand All @@ -107,19 +107,21 @@ procedure TMainForm.dsArticlesBeforePost(DataSet: TDataSet);
var
Res: IRESTResponse;
begin
if not FLoading then
if not fLoading then
begin
if dsArticles.State = dsInsert then
Res := Clt.DataSetInsert('/articles', dsArticles)
Res := fRESTClient.DataSetInsert('/articles', dsArticles)
else
Res := Clt.DataSetUpdate('/articles', dsArticles, dsArticlesid.AsString);
Res := fRESTClient.DataSetUpdate('/articles', dsArticles, dsArticlesid.AsString);
if not(Res.ResponseCode in [200, 201]) then
begin
ShowError(Res);
Abort;
end
else
begin
DataSet.Refresh;
end;
end;
end;

Expand All @@ -133,20 +135,20 @@ procedure TMainForm.dsArticlesBeforeRowRequest(DataSet: TFDDataSet);
var
Res: IRESTResponse;
begin
Res := Clt.doGET('/articles', [DataSet.FieldByName('id').AsString]);
FLoading := true;
Res := fRESTClient.doGET('/articles', [DataSet.FieldByName('id').AsString]);
fLoading := true;
DataSet.LoadFromJSONObjectString(Res.BodyAsString);
FLoading := false;
fLoading := false;
end;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Clt.Free;
fRESTClient.Free;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
Clt := MVCFramework.RESTClient.TRESTClient.Create('localhost', 8080);
fRESTClient := MVCFramework.RESTClient.TRESTClient.Create('localhost', 8080);
end;

procedure TMainForm.ShowError(const AResponse: IRESTResponse);
Expand Down
16 changes: 16 additions & 0 deletions samples/commons/BusinessObjectsU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ interface
MVCFramework.Nullables,
MVCFramework.ActiveRecord,
System.Generics.Collections,
{$IFNDEF LINUX}
Vcl.Graphics,
{$ENDIF}
JsonDataObjects, System.Classes;

type
Expand Down Expand Up @@ -206,14 +208,18 @@ TCustomer = class
FContactFirst: string;
FCity: string;
FContactLast: string;
{$IFNDEF LINUX}
fLogo: TBitmap;
{$ENDIF}
procedure SetAddressLine1(const Value: string);
procedure SetAddressLine2(const Value: string);
procedure SetCity(const Value: string);
procedure SetContactFirst(const Value: string);
procedure SetContactLast(const Value: string);
procedure SetName(const Value: string);
{$IFNDEF LINUX}
procedure SetLogo(const Value: TBitmap);
{$ENDIF}
public
constructor Create;
destructor Destroy; override;
Expand All @@ -225,7 +231,9 @@ TCustomer = class
property AddressLine1: string read FAddressLine1 write SetAddressLine1;
property AddressLine2: string read FAddressLine2 write SetAddressLine2;
property City: string read FCity write SetCity;
{$IFNDEF LINUX}
property Logo: TBitmap read fLogo write SetLogo;
{$ENDIF}
class function GetList: TObjectList<TCustomer>;
end;

Expand Down Expand Up @@ -335,12 +343,16 @@ procedure TPerson.SetMarried(const Value: boolean);
constructor TCustomer.Create;
begin
inherited;
{$IFNDEF LINUX}
fLogo := TBitmap.Create;
{$ENDIF}
end;

destructor TCustomer.Destroy;
begin
{$IFNDEF LINUX}
fLogo.Free;
{$ENDIF}
inherited;
end;

Expand Down Expand Up @@ -404,10 +416,14 @@ procedure TCustomer.SetContactLast(const Value: string);
FContactLast := Value;
end;

{$IFNDEF LINUX}

procedure TCustomer.SetLogo(const Value: TBitmap);
begin
fLogo := Value;
end;
{$ENDIF}


procedure TCustomer.SetName(const Value: string);
begin
Expand Down
Binary file modified samples/data/ACTIVERECORDDB.FDB
Binary file not shown.
Binary file modified samples/data/ORDERSMANAGER_FB30.FDB
Binary file not shown.
3 changes: 2 additions & 1 deletion samples/windowsservice/ServiceU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ implementation

uses
Web.WebReq,
WebModuleUnit1;
WebModuleUnit1, MVCFramework.Commons;

{$R *.DFM}


procedure ServiceController(CtrlCode: DWord); stdcall;
begin
ArticlesService.Controller(CtrlCode);
Expand Down
Loading

0 comments on commit c36cd13

Please sign in to comment.