Skip to content

Commit

Permalink
https://github.com/danieleteti/delphimvcframework/issues/768
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Nov 28, 2024
1 parent 4a97042 commit 04d3133
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions sources/MVCFramework.ActiveRecord.pas
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ TMVCActiveRecord = class
function GetPartitionInfo: TPartitionInfo;
function GetConnection: TFDConnection;
procedure InitTableInfo(const aTableName: String);
class function
CreateQuery(const Unidirectional, DirectExecute: Boolean): TFDQuery;
class function ExecQuery(
const SQL: string;
const Values: array of Variant;
Expand Down Expand Up @@ -1360,15 +1362,15 @@ function TMVCActiveRecord.ExecNonQuery(const SQL: string; RefreshAutoGenerated:
I: Integer;
begin
{ TODO -oDanieleT -cGeneral : Why not a TFDCommand? }
lQry := TFDQuery.Create(nil);
lQry := CreateQuery(True, True);
try
lQry.Connection := GetConnection;
lSQL := SQL;
OnBeforeExecuteSQL(lSQL);
lQry.SQL.Text := lSQL;

lHandled := false;
// lQry.Prepare;

MapObjectToParams(lQry.Params, lHandled);
if not lHandled then
begin
Expand Down Expand Up @@ -4234,13 +4236,8 @@ class function TMVCActiveRecord.ExecQuery(
var
lQry: TFDQuery;
begin
lQry := TFDQuery.Create(nil);
lQry := CreateQuery(Unidirectional, DirectExecute);
try
lQry.FetchOptions.Mode := TFDFetchMode.fmAll;
lQry.FetchOptions.Unidirectional := Unidirectional;
lQry.UpdateOptions.ReadOnly := True;
lQry.ResourceOptions.DirectExecute := DirectExecute; //2023-07-12

if Connection = nil then
begin
lQry.Connection := ActiveRecordConnectionsRegistry.GetCurrent;
Expand Down Expand Up @@ -4804,6 +4801,16 @@ constructor TMVCActiveRecord.Create;
Create(True);
end;

class function TMVCActiveRecord.CreateQuery(const Unidirectional, DirectExecute: Boolean): TFDQuery;
begin
Result := TFDQuery.Create(nil);
Result.FetchOptions.Mode := TFDFetchMode.fmAll;
Result.FetchOptions.Unidirectional := Unidirectional;
Result.UpdateOptions.ReadOnly := True;
Result.UpdateOptions.RequestLive := False;
Result.ResourceOptions.DirectExecute := DirectExecute; //2023-07-12
end;

{ TMVCTransactionContext }

{$IF Defined(CUSTOM_MANAGED_RECORDS)}
Expand Down

0 comments on commit 04d3133

Please sign in to comment.