Skip to content
Permalink
Browse files

Make TDBConnection.GetLastResults generic for all network types, and …

…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 186e4b2eb3aca980209c896501ca561b12d2af33
Showing with 3 additions and 37 deletions.
  1. +3 −37 source/dbconnection.pas
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -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;

0 comments on commit 186e4b2

Please sign in to comment.
You can’t perform that action at this time.