Skip to content

Commit

Permalink
Make TDBConnection.GetLastResults generic for all network types, and …
Browse files Browse the repository at this point in the history
…only override it for MSSQL with a manual query-separator, so we have less code
  • Loading branch information
ansgarbecker committed Dec 28, 2019
1 parent 541d4e2 commit 186e4b2
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions source/dbconnection.pas
Expand Up @@ -408,7 +408,7 @@ TDBConnection = class(TComponent)
function ParseDateTime(Str: String): TDateTime;
function GetKeyColumns(Columns: TTableColumnList; Keys: TTableKeyList): TStringList;
function ConnectionInfo: TStringList; virtual;
function GetLastResults: TDBQueryList; virtual; abstract;
function GetLastResults: TDBQueryList; virtual;
function GetCreateCode(Obj: TDBObject): String; virtual;
procedure PrefetchCreateCode(Objects: TDBObjectList);
function GetSessionVariables(Refresh: Boolean): TDBQuery;
Expand Down Expand Up @@ -509,7 +509,6 @@ TMySQLConnection = class(TDBConnection)
procedure Query(SQL: String; DoStoreResult: Boolean=False; LogCategory: TDBLogCategory=lcSQL); override;
function Ping(Reconnect: Boolean): Boolean; override;
function ConnectionInfo: TStringList; override;
function GetLastResults: TDBQueryList; override;
function GetCreateCode(Obj: TDBObject): String; override;
property LastRawResults: TMySQLRawResults read FLastRawResults;
function MaxAllowedPacket: Int64; override;
Expand Down Expand Up @@ -567,7 +566,6 @@ TPgConnection = class(TDBConnection)
procedure Query(SQL: String; DoStoreResult: Boolean=False; LogCategory: TDBLogCategory=lcSQL); override;
function Ping(Reconnect: Boolean): Boolean; override;
function ConnectionInfo: TStringList; override;
function GetLastResults: TDBQueryList; override;
function GetRowCount(Obj: TDBObject): Int64; override;
property LastRawResults: TPGRawResults read FLastRawResults;
end;
Expand Down Expand Up @@ -595,14 +593,12 @@ TSQLiteConnection = class(TDBConnection)
function GetAllDatabases: TStringList; override;
function GetCharsetTable: TDBQuery; override;
procedure FetchDbObjects(db: String; var Cache: TDBObjectList); override;
//procedure Drop(Obj: TDBObject); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Lib: TSQLiteLib read FLib;
procedure Query(SQL: String; DoStoreResult: Boolean=False; LogCategory: TDBLogCategory=lcSQL); override;
function Ping(Reconnect: Boolean): Boolean; override;
function GetLastResults: TDBQueryList; override;
function GetRowCount(Obj: TDBObject): Int64; override;
property LastRawResults: TSQLiteRawResults read FLastRawResults;
end;
Expand Down Expand Up @@ -3055,13 +3051,13 @@ procedure TSQLiteConnection.Query(SQL: String; DoStoreResult: Boolean=False; Log
end;


function TMySQLConnection.GetLastResults: TDBQueryList;
function TDBConnection.GetLastResults: TDBQueryList;
var
r: TDBQuery;
i: Integer;
begin
Result := TDBQueryList.Create(False);
for i:=Low(FLastRawResults) to High(FLastRawResults) do begin
for i:=0 to ResultCount-1 do begin
r := Parameters.CreateQuery(Self);
r.SQL := FLastQuerySQL;
r.Execute(False, i);
Expand Down Expand Up @@ -3092,36 +3088,6 @@ function TAdoDBConnection.GetLastResults: TDBQueryList;
end;


function TPGConnection.GetLastResults: TDBQueryList;
var
r: TDBQuery;
i: Integer;
begin
Result := TDBQueryList.Create(False);
for i:=Low(FLastRawResults) to High(FLastRawResults) do begin
r := Parameters.CreateQuery(Self);
r.SQL := FLastQuerySQL;
r.Execute(False, i);
Result.Add(r);
end;
end;


function TSQLiteConnection.GetLastResults: TDBQueryList;
var
r: TDBQuery;
i: Integer;
begin
Result := TDBQueryList.Create(False);
for i:=Low(FLastRawResults) to High(FLastRawResults) do begin
r := Parameters.CreateQuery(Self);
r.SQL := FLastQuerySQL;
r.Execute(False, i);
Result.Add(r);
end;
end;


function TMySQLConnection.GetCreateCode(Obj: TDBObject): String;
var
Column: Integer;
Expand Down

0 comments on commit 186e4b2

Please sign in to comment.