Skip to content

Commit

Permalink
Issue#802 (#803)
Browse files Browse the repository at this point in the history
* Issue #546 was missing from the merge.

* #581 - Fix error on removing default connection;

* #583 - Fixes bugs 'Invalid class typecast' when using Active Record and Enumerated Type;

* Fixes rendering in Swagger documentation for TArray type fields.

* It also allows overriding the MapTValueToParam method of the TMVCActiveRecord class.
  • Loading branch information
marcelojaloto authored Jan 6, 2025
1 parent f7a139a commit 3184404
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sources/MVCFramework.ActiveRecord.pas
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ TMVCActiveRecord = class
fConn: TFDConnection;
fSQLGenerator: TMVCSQLGenerator;
fRQL2SQL: TRQL2SQL;
procedure MapTValueToParam(aValue: TValue; const aParam: TFDParam);
function MapNullableTValueToParam(aValue: TValue; const aParam: TFDParam): Boolean;
function GetPrimaryKeyIsAutogenerated: Boolean;
procedure SetPrimaryKeyIsAutogenerated(const Value: Boolean);
Expand All @@ -324,6 +323,7 @@ TMVCActiveRecord = class
function GetCustomTableName: String; virtual;
function GetPartitionInfo: TPartitionInfo;
function GetConnection: TFDConnection;
procedure MapTValueToParam(aValue: TValue; const aParam: TFDParam); virtual;
procedure InitTableInfo(const aTableName: String);
class function
CreateQuery(const Unidirectional, DirectExecute: Boolean): TFDQuery;
Expand Down
13 changes: 12 additions & 1 deletion sources/MVCFramework.Swagger.Commons.pas
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,19 @@ class procedure TMVCSwagger.ExtractJsonSchemaFromClass(const aJsonFieldRoot: TJs
begin
lJsonFieldClass := GetJsonFieldClass(TypeKindToMVCSwagSchemaType(
TRttiDynamicArrayType(lProp.PropertyType).ElementType));

if Assigned(lJsonFieldClass) then
TJsonFieldArray(lJsonField).ItemFieldType := lJsonFieldClass.Create;
begin
if lJsonFieldClass.InheritsFrom(TJsonFieldObject) then
begin
lClass := TRttiDynamicArrayType(lProp.PropertyType).ElementType.AsInstance.MetaclassType;
lJsonFieldObject := TJsonFieldObject.Create;
ExtractJsonSchemaFromClass(lJsonFieldObject, lClass, aHTTPMethod, aIsResponseSchema);
TJsonFieldArray(lJsonField).ItemFieldType := lJsonFieldObject;
end
else
TJsonFieldArray(lJsonField).ItemFieldType := lJsonFieldClass.Create;
end;
end
else if lJsonField is TJsonFieldEnum then /// Extract enumerator information
begin
Expand Down

0 comments on commit 3184404

Please sign in to comment.