|
@@ -19,17 +19,20 @@ unit sqldbrestbridge;
|
|
interface
|
|
interface
|
|
|
|
|
|
uses
|
|
uses
|
|
- Classes, SysUtils, DB, SQLDB, httpdefs, httproute, fpjson, sqldbrestschema, sqldbrestio, sqldbrestdata, sqldbrestauth;
|
|
|
|
|
|
+ Classes, SysUtils, DB, SQLDB, httpdefs, httproute, fpjson, sqldbrestschema, sqldbrestio, sqldbrestdata, sqldbrestauth, sqldbpool;
|
|
|
|
|
|
Type
|
|
Type
|
|
- TRestDispatcherOption = (rdoConnectionInURL, // Route includes connection :Connection/:Resource[/:ID]
|
|
|
|
- rdoExposeMetadata, // expose metadata resource /metadata[/:Resource]
|
|
|
|
- rdoCustomView, // Expose custom view /customview
|
|
|
|
- rdoHandleCORS, // Handle CORS requests
|
|
|
|
- rdoAccessCheckNeedsDB, // Authenticate after connection to database was made.
|
|
|
|
- rdoConnectionResource, // Enable connection managament through /_connection[/:Conn] resource
|
|
|
|
- rdoEmptyCORSDomainToOrigin // if CORSAllowedOrigins is empty CORS requests will mirror Origin instead of *
|
|
|
|
- // rdoServerInfo // Enable querying server info through /_serverinfo resource
|
|
|
|
|
|
+ TRestDispatcherOption = (rdoConnectionInURL, // Route includes connection :Connection/:Resource[/:ID]
|
|
|
|
+ rdoExposeMetadata, // expose metadata resource /metadata[/:Resource]
|
|
|
|
+ rdoCustomView, // Expose custom view /customview
|
|
|
|
+ rdoHandleCORS, // Handle CORS requests
|
|
|
|
+ rdoAccessCheckNeedsDB, // Authenticate after connection to database was made.
|
|
|
|
+ rdoConnectionResource, // Enable connection managament through /_connection[/:Conn] resource
|
|
|
|
+ rdoEmptyCORSDomainToOrigin, // if CORSAllowedOrigins is empty CORS requests will mirror Origin instead of *
|
|
|
|
+ // rdoServerInfo // Enable querying server info through /_serverinfo resource
|
|
|
|
+ rdoLegacyPut, // Makes PUT simulate PATCH : Not all values are required, missing values will be gotten from previous record.
|
|
|
|
+ rdoAllowNoRecordUpdates, // Check rows affected, rowsaffected = 0 is OK.
|
|
|
|
+ rdoAllowMultiRecordUpdates // Check rows affected, rowsaffected > 1 is OK.
|
|
);
|
|
);
|
|
|
|
|
|
TRestDispatcherOptions = set of TRestDispatcherOption;
|
|
TRestDispatcherOptions = set of TRestDispatcherOption;
|
|
@@ -53,27 +56,15 @@ Type
|
|
|
|
|
|
{ TSQLDBRestConnection }
|
|
{ TSQLDBRestConnection }
|
|
|
|
|
|
- TSQLDBRestConnection = Class(TCollectionItem)
|
|
|
|
|
|
+ TSQLDBRestConnection = Class(TSQLDBConnectionDef)
|
|
private
|
|
private
|
|
- FCharSet: UTF8String;
|
|
|
|
FConnection: TSQLConnection;
|
|
FConnection: TSQLConnection;
|
|
- FConnectionType: String;
|
|
|
|
- FDatabaseName: UTF8String;
|
|
|
|
FEnabled: Boolean;
|
|
FEnabled: Boolean;
|
|
- FHostName: UTF8String;
|
|
|
|
- FName: UTF8String;
|
|
|
|
- FParams: TStrings;
|
|
|
|
- FPassword: UTF8String;
|
|
|
|
- FPort: Word;
|
|
|
|
- FRole: UTF8String;
|
|
|
|
FSchemaName: UTF8String;
|
|
FSchemaName: UTF8String;
|
|
- FUserName: UTF8String;
|
|
|
|
FNotifier : TComponent;
|
|
FNotifier : TComponent;
|
|
- function GetName: UTF8String;
|
|
|
|
procedure SetConnection(AValue: TSQLConnection);
|
|
procedure SetConnection(AValue: TSQLConnection);
|
|
- procedure SetParams(AValue: TStrings);
|
|
|
|
Protected
|
|
Protected
|
|
- Function GetDisplayName: string; override;
|
|
|
|
|
|
+ function GetName: UTF8String; override;
|
|
// For use in the REST Connection resource
|
|
// For use in the REST Connection resource
|
|
Property SchemaName : UTF8String Read FSchemaName Write FSchemaName;
|
|
Property SchemaName : UTF8String Read FSchemaName Write FSchemaName;
|
|
Public
|
|
Public
|
|
@@ -84,33 +75,11 @@ Type
|
|
Published
|
|
Published
|
|
// Always use this connection instance
|
|
// Always use this connection instance
|
|
Property SingleConnection : TSQLConnection Read FConnection Write SetConnection;
|
|
Property SingleConnection : TSQLConnection Read FConnection Write SetConnection;
|
|
- // Allow this connection to be used.
|
|
|
|
- Property Enabled : Boolean Read FEnabled Write FEnabled default true;
|
|
|
|
- // TSQLConnector type
|
|
|
|
- property ConnectionType : String Read FConnectionType Write FConnectionType;
|
|
|
|
- // Name for this connection
|
|
|
|
- Property Name : UTF8String Read GetName Write FName;
|
|
|
|
- // Database user password
|
|
|
|
- property Password : UTF8String read FPassword write FPassword;
|
|
|
|
- // Database username
|
|
|
|
- property UserName : UTF8String read FUserName write FUserName;
|
|
|
|
- // Database character set
|
|
|
|
- property CharSet : UTF8String read FCharSet write FCharSet;
|
|
|
|
- // Database hostname
|
|
|
|
- property HostName : UTF8String Read FHostName Write FHostName;
|
|
|
|
- // Database role
|
|
|
|
- Property Role : UTF8String read FRole write FRole;
|
|
|
|
- // Database database name
|
|
|
|
- property DatabaseName : UTF8String Read FDatabaseName Write FDatabaseName;
|
|
|
|
- // Other parameters
|
|
|
|
- Property Params : TStrings Read FParams Write SetParams;
|
|
|
|
- // Port DB is listening on
|
|
|
|
- Property Port : Word Read FPort Write FPort;
|
|
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
|
|
|
|
{ TSQLDBRestConnectionList }
|
|
{ TSQLDBRestConnectionList }
|
|
|
|
|
|
- TSQLDBRestConnectionList = Class(TCollection)
|
|
|
|
|
|
+ TSQLDBRestConnectionList = Class(TSQLDBConnectionDefList)
|
|
private
|
|
private
|
|
function GetConn(aIndex : integer): TSQLDBRestConnection;
|
|
function GetConn(aIndex : integer): TSQLDBRestConnection;
|
|
procedure SetConn(aIndex : integer; AValue: TSQLDBRestConnection);
|
|
procedure SetConn(aIndex : integer; AValue: TSQLDBRestConnection);
|
|
@@ -178,7 +147,7 @@ Type
|
|
|
|
|
|
TResourceAuthorizedEvent = Procedure (Sender : TObject; aRequest : TRequest; Const aResource : UTF8String; var AllowResource : Boolean) of object;
|
|
TResourceAuthorizedEvent = Procedure (Sender : TObject; aRequest : TRequest; Const aResource : UTF8String; var AllowResource : Boolean) of object;
|
|
TGetConnectionNameEvent = Procedure(Sender : TObject; aRequest : TRequest; Const AResource : String; var AConnectionName : UTF8String) of object;
|
|
TGetConnectionNameEvent = Procedure(Sender : TObject; aRequest : TRequest; Const AResource : String; var AConnectionName : UTF8String) of object;
|
|
- TGetConnectionEvent = Procedure(Sender : TObject; aDef : TSQLDBRestConnection; var aConnection : TSQLConnection) of object;
|
|
|
|
|
|
+ TGetConnectionEvent = Procedure(Sender : TObject; aDef : TSQLDBConnectionDef; var aConnection : TSQLConnection) of object;
|
|
TRestExceptionEvent = Procedure(Sender : TObject; aRequest : TRequest; Const AResource : string; E : Exception) of object;
|
|
TRestExceptionEvent = Procedure(Sender : TObject; aRequest : TRequest; Const AResource : string; E : Exception) of object;
|
|
TRestOperationEvent = Procedure(Sender : TObject; aConn: TSQLConnection; aResource : TSQLDBRestResource) of object;
|
|
TRestOperationEvent = Procedure(Sender : TObject; aConn: TSQLConnection; aResource : TSQLDBRestResource) of object;
|
|
TRestGetFormatEvent = Procedure(Sender : TObject; aRest : TRequest; var aFormat : String) of object;
|
|
TRestGetFormatEvent = Procedure(Sender : TObject; aRest : TRequest; var aFormat : String) of object;
|
|
@@ -190,6 +159,7 @@ Type
|
|
Class Var FDBHandlerClass : TSQLDBRestDBHandlerClass;
|
|
Class Var FDBHandlerClass : TSQLDBRestDBHandlerClass;
|
|
private
|
|
private
|
|
FAdminUserIDs: TStrings;
|
|
FAdminUserIDs: TStrings;
|
|
|
|
+ FConnectionManager: TSQLDBConnectionManager;
|
|
FCORSAllowCredentials: Boolean;
|
|
FCORSAllowCredentials: Boolean;
|
|
FCORSAllowedOrigins: String;
|
|
FCORSAllowedOrigins: String;
|
|
FCORSMaxAge: Integer;
|
|
FCORSMaxAge: Integer;
|
|
@@ -234,10 +204,15 @@ Type
|
|
FMetadataItemRoute: THTTPRoute;
|
|
FMetadataItemRoute: THTTPRoute;
|
|
FStatus: TRestStatusConfig;
|
|
FStatus: TRestStatusConfig;
|
|
FStrings: TRestStringsConfig;
|
|
FStrings: TRestStringsConfig;
|
|
|
|
+ FAfterDatabaseRead: TRestDatabaseEvent;
|
|
|
|
+ FAfterDatabaseUpdate: TRestDatabaseEvent;
|
|
|
|
+ FBeforeDatabaseRead: TRestDatabaseEvent;
|
|
|
|
+ FBeforeDatabaseUpdate: TRestDatabaseEvent;
|
|
function GetRoutesRegistered: Boolean;
|
|
function GetRoutesRegistered: Boolean;
|
|
procedure SetActive(AValue: Boolean);
|
|
procedure SetActive(AValue: Boolean);
|
|
procedure SetAdminUserIDS(AValue: TStrings);
|
|
procedure SetAdminUserIDS(AValue: TStrings);
|
|
procedure SetAuthenticator(AValue: TRestAuthenticator);
|
|
procedure SetAuthenticator(AValue: TRestAuthenticator);
|
|
|
|
+ procedure SetConnectionManager(AValue: TSQLDBConnectionManager);
|
|
procedure SetConnections(AValue: TSQLDBRestConnectionList);
|
|
procedure SetConnections(AValue: TSQLDBRestConnectionList);
|
|
procedure SetDispatchOptions(AValue: TRestDispatcherOptions);
|
|
procedure SetDispatchOptions(AValue: TRestDispatcherOptions);
|
|
procedure SetSchemas(AValue: TSQLDBRestSchemaList);
|
|
procedure SetSchemas(AValue: TSQLDBRestSchemaList);
|
|
@@ -245,6 +220,7 @@ Type
|
|
procedure SetStrings(AValue: TRestStringsConfig);
|
|
procedure SetStrings(AValue: TRestStringsConfig);
|
|
Protected
|
|
Protected
|
|
// Logging
|
|
// Logging
|
|
|
|
+ procedure DoConnectionManagerLog(Sender: TObject; const Msg: string); virtual;
|
|
Function MustLog(aLog : TRestDispatcherLogOption) : Boolean; inline;
|
|
Function MustLog(aLog : TRestDispatcherLogOption) : Boolean; inline;
|
|
procedure DoSQLLog(Sender: TObject; EventType: TDBEventType; const Msg: String); virtual;
|
|
procedure DoSQLLog(Sender: TObject; EventType: TDBEventType; const Msg: String); virtual;
|
|
procedure DoLog(aLog: TRestDispatcherLogOption; IO : TRestIO; const aMessage: UTF8String); virtual;
|
|
procedure DoLog(aLog: TRestDispatcherLogOption; IO : TRestIO; const aMessage: UTF8String); virtual;
|
|
@@ -253,8 +229,10 @@ Type
|
|
// Auxiliary methods.
|
|
// Auxiliary methods.
|
|
Procedure Loaded; override;
|
|
Procedure Loaded; override;
|
|
Procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
Procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
- function FindConnection(IO: TRestIO): TSQLDBRestConnection;
|
|
|
|
|
|
+ function FindConnection(IO: TRestIO): TSQLDBConnectionDef;
|
|
|
|
+ function GetConnectionManager : TSQLDBConnectionmanager;
|
|
// Factory methods. Override these to customize various helper classes.
|
|
// Factory methods. Override these to customize various helper classes.
|
|
|
|
+ Function CreateConnectionManager : TSQLDBConnectionmanager;
|
|
function CreateConnection: TSQLConnection; virtual;
|
|
function CreateConnection: TSQLConnection; virtual;
|
|
Function CreateConnectionList : TSQLDBRestConnectionList; virtual;
|
|
Function CreateConnectionList : TSQLDBRestConnectionList; virtual;
|
|
Function CreateSchemaList : TSQLDBRestSchemaList; virtual;
|
|
Function CreateSchemaList : TSQLDBRestSchemaList; virtual;
|
|
@@ -267,14 +245,14 @@ Type
|
|
function GetInputFormat(IO: TRestIO): String; virtual;
|
|
function GetInputFormat(IO: TRestIO): String; virtual;
|
|
function GetOutputFormat(IO: TRestIO): String; virtual;
|
|
function GetOutputFormat(IO: TRestIO): String; virtual;
|
|
function GetConnectionName(IO: TRestIO): UTF8String;
|
|
function GetConnectionName(IO: TRestIO): UTF8String;
|
|
- function GetSQLConnection(aConnection: TSQLDBRestConnection; Out aTransaction : TSQLTransaction): TSQLConnection; virtual;
|
|
|
|
- procedure DoneSQLConnection(aConnection: TSQLDBRestConnection; AConn: TSQLConnection; aTransaction : TSQLTransaction); virtual;
|
|
|
|
|
|
+ function GetSQLConnection(aConnection: TSQLDBConnectionDef; Out aTransaction : TSQLTransaction): TSQLConnection; virtual;
|
|
|
|
+ procedure DoneSQLConnection(aConnection: TSQLDBConnectionDef; AConn: TSQLConnection; aTransaction : TSQLTransaction); virtual;
|
|
// Connections dataset API
|
|
// Connections dataset API
|
|
procedure ConnectionsToDataset(D: TDataset); virtual;
|
|
procedure ConnectionsToDataset(D: TDataset); virtual;
|
|
procedure DoConnectionDelete(DataSet: TDataSet); virtual;
|
|
procedure DoConnectionDelete(DataSet: TDataSet); virtual;
|
|
procedure DoConnectionPost(DataSet: TDataSet);virtual;
|
|
procedure DoConnectionPost(DataSet: TDataSet);virtual;
|
|
procedure DatasetToConnection(D: TDataset; C: TSQLDBRestConnection); virtual;
|
|
procedure DatasetToConnection(D: TDataset; C: TSQLDBRestConnection); virtual;
|
|
- procedure ConnectionToDataset(C: TSQLDBRestConnection; D: TDataset); virtual;
|
|
|
|
|
|
+ procedure ConnectionToDataset(C: TSQLDBConnectionDef; D: TDataset); virtual;
|
|
procedure DoConnectionResourceAllowed(aSender: TObject; aContext: TBaseRestContext; var allowResource: Boolean);
|
|
procedure DoConnectionResourceAllowed(aSender: TObject; aContext: TBaseRestContext; var allowResource: Boolean);
|
|
// Error handling
|
|
// Error handling
|
|
procedure CreateErrorContent(IO: TRestIO; aCode: Integer; AExtraMessage: UTF8String); virtual;
|
|
procedure CreateErrorContent(IO: TRestIO; aCode: Integer; AExtraMessage: UTF8String); virtual;
|
|
@@ -312,8 +290,8 @@ Type
|
|
procedure DoRegisterRoutes; virtual;
|
|
procedure DoRegisterRoutes; virtual;
|
|
procedure DoHandleEvent(IsBefore : Boolean;IO: TRestIO); virtual;
|
|
procedure DoHandleEvent(IsBefore : Boolean;IO: TRestIO); virtual;
|
|
function ResolvedCORSAllowedOrigins(aRequest: TRequest): String; virtual;
|
|
function ResolvedCORSAllowedOrigins(aRequest: TRequest): String; virtual;
|
|
- procedure HandleCORSRequest(aConnection: TSQLDBRestConnection; IO: TRestIO); virtual;
|
|
|
|
- procedure HandleResourceRequest(aConnection : TSQLDBRestConnection; IO: TRestIO); virtual;
|
|
|
|
|
|
+ procedure HandleCORSRequest(aConnection: TSQLDBConnectionDef; IO: TRestIO); virtual;
|
|
|
|
+ procedure HandleResourceRequest(aConnection : TSQLDBConnectionDef; IO: TRestIO); virtual;
|
|
procedure DoHandleRequest(IO: TRestIO); virtual;
|
|
procedure DoHandleRequest(IO: TRestIO); virtual;
|
|
Public
|
|
Public
|
|
Class Procedure SetIOClass (aClass: TRestIOClass);
|
|
Class Procedure SetIOClass (aClass: TRestIOClass);
|
|
@@ -340,6 +318,8 @@ Type
|
|
Property Schemas : TSQLDBRestSchemaList Read FSchemas Write SetSchemas;
|
|
Property Schemas : TSQLDBRestSchemaList Read FSchemas Write SetSchemas;
|
|
// Base URL
|
|
// Base URL
|
|
property BasePath : UTF8String Read FBaseURL Write FBaseURL;
|
|
property BasePath : UTF8String Read FBaseURL Write FBaseURL;
|
|
|
|
+ // Connection manager to use
|
|
|
|
+ property ConnectionManager : TSQLDBConnectionManager Read GetConnectionManager Write SetConnectionManager;
|
|
// Default connection to use if none is detected from request/schema
|
|
// Default connection to use if none is detected from request/schema
|
|
// This connection will also be used to authenticate the user for connection API,
|
|
// This connection will also be used to authenticate the user for connection API,
|
|
// so it must be set if you use SQL to authenticate the user.
|
|
// so it must be set if you use SQL to authenticate the user.
|
|
@@ -402,6 +382,12 @@ Type
|
|
Property BeforeDelete : TRestOperationEvent Read FBeforeDelete Write FBeforeDelete;
|
|
Property BeforeDelete : TRestOperationEvent Read FBeforeDelete Write FBeforeDelete;
|
|
// Called After a DELETE request.
|
|
// Called After a DELETE request.
|
|
Property AfterDelete : TRestOperationEvent Read FAfterDelete Write FAfterDelete;
|
|
Property AfterDelete : TRestOperationEvent Read FAfterDelete Write FAfterDelete;
|
|
|
|
+ // Events called when accessing the database during read operations
|
|
|
|
+ Property BeforeDatabaseRead: TRestDatabaseEvent Read FBeforeDatabaseRead Write FBeforeDatabaseRead;
|
|
|
|
+ Property AfterDatabaseRead : TRestDatabaseEvent Read FAfterDatabaseRead Write FAfterDatabaseRead;
|
|
|
|
+ // Events called when accessing the database during update operations
|
|
|
|
+ Property BeforeDatabaseUpdate : TRestDatabaseEvent Read FBeforeDatabaseUpdate Write FBeforeDatabaseUpdate;
|
|
|
|
+ Property AfterDatabaseUpdate : TRestDatabaseEvent Read FAfterDatabaseUpdate Write FAfterDatabaseUpdate;
|
|
// Called when logging
|
|
// Called when logging
|
|
Property OnLog : TRestLogEvent Read FOnLog Write FOnLog;
|
|
Property OnLog : TRestLogEvent Read FOnLog Write FOnLog;
|
|
end;
|
|
end;
|
|
@@ -557,6 +543,12 @@ begin
|
|
FActive:=AValue;
|
|
FActive:=AValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TSQLDBRestDispatcher.DoConnectionManagerLog(Sender: TObject;
|
|
|
|
+ const Msg: string);
|
|
|
|
+begin
|
|
|
|
+ DoLog(rloConnection,Nil,Msg);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TSQLDBRestDispatcher.GetRoutesRegistered: Boolean;
|
|
function TSQLDBRestDispatcher.GetRoutesRegistered: Boolean;
|
|
begin
|
|
begin
|
|
Result:=FItemRoute<>Nil;
|
|
Result:=FItemRoute<>Nil;
|
|
@@ -578,6 +570,25 @@ begin
|
|
FAuthenticator.FreeNotification(Self);
|
|
FAuthenticator.FreeNotification(Self);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+
|
|
|
|
+procedure TSQLDBRestDispatcher.SetConnectionManager(AValue: TSQLDBConnectionManager);
|
|
|
|
+begin
|
|
|
|
+ if FConnectionManager=AValue then Exit;
|
|
|
|
+ if Assigned(FCOnnectionManager) then
|
|
|
|
+ begin
|
|
|
|
+ if (csSubComponent in FConnectionManager.ComponentStyle)
|
|
|
|
+ and (FConnectionManager.Owner=Self) then
|
|
|
|
+ FreeAndNil(FConnectionManager)
|
|
|
|
+ else
|
|
|
|
+ FConnectionManager.RemoveFreeNotification(Self) ;
|
|
|
|
+ end;
|
|
|
|
+ FConnectionManager:=AValue;
|
|
|
|
+ if Assigned(FConnectionManager) then
|
|
|
|
+ FConnectionManager.FreeNotification(Self)
|
|
|
|
+ else
|
|
|
|
+ GetConnectionManager;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TSQLDBRestDispatcher.SetSchemas(AValue: TSQLDBRestSchemaList);
|
|
procedure TSQLDBRestDispatcher.SetSchemas(AValue: TSQLDBRestSchemaList);
|
|
begin
|
|
begin
|
|
if FSchemas=AValue then Exit;
|
|
if FSchemas=AValue then Exit;
|
|
@@ -1122,11 +1133,16 @@ begin
|
|
M:=aRequest.CustomHeaders.Values['Access-Control-Request-Method'];
|
|
M:=aRequest.CustomHeaders.Values['Access-Control-Request-Method'];
|
|
Case lowercase(M) of
|
|
Case lowercase(M) of
|
|
'get' : Result:=roGet;
|
|
'get' : Result:=roGet;
|
|
- 'put' : Result:=roPut;
|
|
|
|
|
|
+ 'put' :
|
|
|
|
+ begin
|
|
|
|
+ Result:=roPut;
|
|
|
|
+
|
|
|
|
+ end;
|
|
'post' : Result:=roPost;
|
|
'post' : Result:=roPost;
|
|
'delete' : Result:=roDelete;
|
|
'delete' : Result:=roDelete;
|
|
'options' : Result:=roOptions;
|
|
'options' : Result:=roOptions;
|
|
'head' : Result:=roHead;
|
|
'head' : Result:=roHead;
|
|
|
|
+ 'patch' : Result:=roPatch;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1183,7 +1199,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TSQLDBRestDispatcher.GetSQLConnection(
|
|
function TSQLDBRestDispatcher.GetSQLConnection(
|
|
- aConnection: TSQLDBRestConnection; out aTransaction: TSQLTransaction
|
|
|
|
|
|
+ aConnection: TSQLDBConnectionDef; out aTransaction: TSQLTransaction
|
|
): TSQLConnection;
|
|
): TSQLConnection;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -1191,49 +1207,120 @@ begin
|
|
aTransaction:=Nil;
|
|
aTransaction:=Nil;
|
|
if aConnection=Nil then
|
|
if aConnection=Nil then
|
|
exit;
|
|
exit;
|
|
- Result:=aConnection.SingleConnection;
|
|
|
|
|
|
+ if aConnection is TSQLDBRestConnection then
|
|
|
|
+ Result:=TSQLDBRestConnection(aConnection).SingleConnection;
|
|
if (Result=Nil) then
|
|
if (Result=Nil) then
|
|
begin
|
|
begin
|
|
if Assigned(OnGetConnection) then
|
|
if Assigned(OnGetConnection) then
|
|
OnGetConnection(Self,aConnection,Result);
|
|
OnGetConnection(Self,aConnection,Result);
|
|
if (Result=Nil) then
|
|
if (Result=Nil) then
|
|
- begin
|
|
|
|
- Result:=CreateConnection;
|
|
|
|
- aConnection.ConfigConnection(Result);
|
|
|
|
- aConnection.SingleConnection:=Result;
|
|
|
|
- end;
|
|
|
|
|
|
+ Result:=GetConnectionManager.GetConnection(aConnection);
|
|
end;
|
|
end;
|
|
If (Result is TRestSQLConnector) then
|
|
If (Result is TRestSQLConnector) then
|
|
TRestSQLConnector(Result).StartUsing;
|
|
TRestSQLConnector(Result).StartUsing;
|
|
- aTransaction:=TSQLTransaction.Create(Self);
|
|
|
|
- aTransaction.Database:=Result;
|
|
|
|
|
|
+ if Result.Transaction=Nil then
|
|
|
|
+ begin
|
|
|
|
+ aTransaction:=TSQLTransaction.Create(Result);
|
|
|
|
+ aTransaction.Database:=Result;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ aTransaction:=Result.Transaction;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TSQLDBRestDispatcher.DoHandleEvent(IsBefore: Boolean; IO: TRestIO);
|
|
procedure TSQLDBRestDispatcher.DoHandleEvent(IsBefore: Boolean; IO: TRestIO);
|
|
|
|
|
|
Var
|
|
Var
|
|
R : TRestOperationEvent;
|
|
R : TRestOperationEvent;
|
|
|
|
+ Evt,ResEvt : TRestDatabaseEvent;
|
|
|
|
+ BP :TSQLDBRestBusinessProcessor;
|
|
|
|
|
|
begin
|
|
begin
|
|
|
|
+ Evt:=Nil;
|
|
|
|
+ ResEvt:=Nil;
|
|
R:=Nil;
|
|
R:=Nil;
|
|
|
|
+ BP:=TSQLDBRestBusinessProcessor(IO.Resource.BusinessProcessor);
|
|
if isBefore then
|
|
if isBefore then
|
|
Case IO.Operation of
|
|
Case IO.Operation of
|
|
- roGet : R:=FBeforeGet;
|
|
|
|
- roPut : R:=FBeforePut;
|
|
|
|
- roPost : R:=FBeforePost;
|
|
|
|
- roDelete : R:=FBeforeDelete;
|
|
|
|
|
|
+ roGet :
|
|
|
|
+ begin
|
|
|
|
+ R:=FBeforeGet;
|
|
|
|
+ Evt:=BeforeDatabaseRead;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.BeforeDatabaseRead;
|
|
|
|
+ end;
|
|
|
|
+ roHead :
|
|
|
|
+ begin
|
|
|
|
+ Evt:=BeforeDatabaseRead;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.BeforeDatabaseRead;
|
|
|
|
+ end;
|
|
|
|
+ roPut :
|
|
|
|
+ begin
|
|
|
|
+ R:=FBeforePut;
|
|
|
|
+ Evt:=BeforeDatabaseUpdate;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.BeforeDatabaseUpdate;
|
|
|
|
+ end;
|
|
|
|
+ roPost :
|
|
|
|
+ begin
|
|
|
|
+ R:=FBeforePost;
|
|
|
|
+ Evt:=BeforeDatabaseUpdate;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.BeforeDatabaseUpdate;
|
|
|
|
+ end;
|
|
|
|
+ roDelete :
|
|
|
|
+ begin
|
|
|
|
+ R:=FBeforeDelete;
|
|
|
|
+ Evt:=BeforeDatabaseUpdate;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.BeforeDatabaseUpdate;
|
|
|
|
+ end;
|
|
else
|
|
else
|
|
R:=Nil;
|
|
R:=Nil;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
Case IO.Operation of
|
|
Case IO.Operation of
|
|
- roGet : R:=FAfterGet;
|
|
|
|
- roPut : R:=FAfterPut;
|
|
|
|
- roPost : R:=FAfterPost;
|
|
|
|
- roDelete : R:=FAfterDelete;
|
|
|
|
|
|
+ roGet :
|
|
|
|
+ begin
|
|
|
|
+ R:=FAfterGet;
|
|
|
|
+ Evt:=AfterDatabaseRead;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.AfterDatabaseRead;
|
|
|
|
+ end;
|
|
|
|
+ roHead :
|
|
|
|
+ begin
|
|
|
|
+ Evt:=AfterDatabaseRead;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.AfterDatabaseRead;
|
|
|
|
+ end;
|
|
|
|
+ roPut :
|
|
|
|
+ begin
|
|
|
|
+ R:=FAfterPut;
|
|
|
|
+ Evt:=AfterDatabaseUpdate;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.AfterDatabaseUpdate;
|
|
|
|
+ end;
|
|
|
|
+ roPost :
|
|
|
|
+ begin
|
|
|
|
+ R:=FAfterPost;
|
|
|
|
+ Evt:=AfterDatabaseUpdate;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.AfterDatabaseUpdate;
|
|
|
|
+ end;
|
|
|
|
+ roDelete :
|
|
|
|
+ begin
|
|
|
|
+ R:=FAfterDelete;
|
|
|
|
+ Evt:=AfterDatabaseUpdate;
|
|
|
|
+ if assigned(BP) then
|
|
|
|
+ ResEvt:=BP.AfterDatabaseUpdate;
|
|
|
|
+ end;
|
|
else
|
|
else
|
|
R:=Nil;
|
|
R:=Nil;
|
|
end;
|
|
end;
|
|
|
|
+ If Assigned(Evt) then
|
|
|
|
+ Evt(Self,IO.OPeration,IO.RestContext,IO.Resource);
|
|
|
|
+ If Assigned(ResEvt) then
|
|
|
|
+ ResEvt(Self,IO.Operation,IO.RestContext,IO.Resource);
|
|
If Assigned(R) then
|
|
If Assigned(R) then
|
|
R(Self,IO.Connection,IO.Resource)
|
|
R(Self,IO.Connection,IO.Resource)
|
|
end;
|
|
end;
|
|
@@ -1241,39 +1328,48 @@ end;
|
|
|
|
|
|
|
|
|
|
procedure TSQLDBRestDispatcher.DoneSQLConnection(
|
|
procedure TSQLDBRestDispatcher.DoneSQLConnection(
|
|
- aConnection: TSQLDBRestConnection; AConn: TSQLConnection;
|
|
|
|
|
|
+ aConnection: TSQLDBConnectionDef; AConn: TSQLConnection;
|
|
aTransaction: TSQLTransaction);
|
|
aTransaction: TSQLTransaction);
|
|
|
|
|
|
Var
|
|
Var
|
|
- NeedNil : Boolean;
|
|
|
|
|
|
+ RConn : TSQLDBRestConnection absolute aConnection;
|
|
|
|
|
|
begin
|
|
begin
|
|
- FreeAndNil(aTransaction);
|
|
|
|
- if (aConn is TRestSQLConnector) then
|
|
|
|
- begin
|
|
|
|
- NeedNil:= (aConnection.SingleConnection=aConn) ;
|
|
|
|
- if TRestSQLConnector(aConn).DoneUsing then
|
|
|
|
- FreeAndNil(aConn);
|
|
|
|
- If NeedNil then
|
|
|
|
- aConnection.SingleConnection:=Nil;
|
|
|
|
- end;
|
|
|
|
|
|
+ if aTransaction<>aConn.Transaction then
|
|
|
|
+ FreeAndNil(aTransaction);
|
|
|
|
+ if Not ((aConnection is TSQLDBRestConnection) and (RConn.SingleConnection=aConn)) then
|
|
|
|
+ if not GetConnectionManager.ReleaseConnection(aConn) then
|
|
|
|
+ aConn.Free;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TSQLDBRestDispatcher.CreateDBHandler(IO: TRestIO): TSQLDBRestDBHandler;
|
|
function TSQLDBRestDispatcher.CreateDBHandler(IO: TRestIO): TSQLDBRestDBHandler;
|
|
|
|
|
|
|
|
+Var
|
|
|
|
+ Opts : TSQLDBRestDBHandlerOptions;
|
|
|
|
+
|
|
|
|
+
|
|
begin
|
|
begin
|
|
Result:=FDBHandlerClass.Create(Self) ;
|
|
Result:=FDBHandlerClass.Create(Self) ;
|
|
Result.Init(IO,FStrings,TSQLQuery);
|
|
Result.Init(IO,FStrings,TSQLQuery);
|
|
Result.EnforceLimit:=Self.EnforceLimit;
|
|
Result.EnforceLimit:=Self.EnforceLimit;
|
|
|
|
+ opts:=[];
|
|
|
|
+ if rdoLegacyPut in DispatchOptions then
|
|
|
|
+ Include(opts,rhoLegacyPUT);
|
|
|
|
+ if ([rdoAllowNoRecordUpdates,rdoAllowMultiRecordUpdates] * DispatchOptions)<>[] then
|
|
|
|
+ Include(opts,rhoCheckupdateCount);
|
|
|
|
+ if (rdoAllowMultiRecordUpdates in DispatchOptions) then
|
|
|
|
+ Include(opts,rhoAllowMultiUpdate);
|
|
|
|
+ // Options may have been set in handler class, make sure we don't unset any.
|
|
|
|
+ Result.Options:=Result.Options+Opts;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TSQLDBRestDispatcher.SetDefaultResponsecode(IO : TRestIO);
|
|
procedure TSQLDBRestDispatcher.SetDefaultResponsecode(IO : TRestIO);
|
|
|
|
|
|
Const
|
|
Const
|
|
- DefaultCodes : Array[TRestOperation] of TRestStatus = (rsError,rsGetOK,rsPOSTOK,rsPUTOK,rsDeleteOK,rsCORSOK,rsGetOK);
|
|
|
|
- DefaultTexts : Array[TRestOperation] of string = ('Internal Error','OK','Created','OK','No content','OK','OK');
|
|
|
|
|
|
+ DefaultCodes : Array[TRestOperation] of TRestStatus = (rsError,rsGetOK,rsPOSTOK,rsPUTOK,rsDeleteOK,rsCORSOK,rsGetOK,rsPatchOK);
|
|
|
|
+ DefaultTexts : Array[TRestOperation] of string = ('Internal Error','OK','Created','OK','No content','OK','OK','OK');
|
|
|
|
|
|
Var
|
|
Var
|
|
aCode : TRestStatus;
|
|
aCode : TRestStatus;
|
|
@@ -1467,7 +1563,10 @@ begin
|
|
C.SchemaName:=D.FieldByName('exposeSchemaName').AsString;
|
|
C.SchemaName:=D.FieldByName('exposeSchemaName').AsString;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TSQLDBRestDispatcher.ConnectionToDataset(C : TSQLDBRestConnection;D: TDataset);
|
|
|
|
|
|
+procedure TSQLDBRestDispatcher.ConnectionToDataset(C : TSQLDBConnectionDef;D: TDataset);
|
|
|
|
+
|
|
|
|
+Var
|
|
|
|
+ RestDef : TSQLDBRestConnection absolute C;
|
|
|
|
|
|
begin
|
|
begin
|
|
D.FieldByName('key').AsWideString:=UTF8Decode(C.Name);
|
|
D.FieldByName('key').AsWideString:=UTF8Decode(C.Name);
|
|
@@ -1481,8 +1580,17 @@ begin
|
|
D.FieldByName('dbRole').AsString:=C.Role;
|
|
D.FieldByName('dbRole').AsString:=C.Role;
|
|
D.FieldByName('dbPort').AsInteger:=C.Port;
|
|
D.FieldByName('dbPort').AsInteger:=C.Port;
|
|
D.FieldByName('enabled').AsBoolean:=C.Enabled;
|
|
D.FieldByName('enabled').AsBoolean:=C.Enabled;
|
|
- D.FieldByName('expose').AsBoolean:=(C.SchemaName<>'');
|
|
|
|
- D.FieldByName('exposeSchemaName').AsString:=C.SchemaName;
|
|
|
|
|
|
+ if C is TSQLDBRestConnection then
|
|
|
|
+ begin
|
|
|
|
+ D.FieldByName('expose').AsBoolean:=(RestDef.SchemaName<>'');
|
|
|
|
+ D.FieldByName('exposeSchemaName').AsString:=RestDef.SchemaName;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ D.FieldByName('expose').AsBoolean:=False;
|
|
|
|
+ D.FieldByName('exposeSchemaName').AsString:='';
|
|
|
|
+ end;
|
|
|
|
+
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TSQLDBRestDispatcher.ConnectionsToDataset(D: TDataset);
|
|
procedure TSQLDBRestDispatcher.ConnectionsToDataset(D: TDataset);
|
|
@@ -1689,7 +1797,7 @@ begin
|
|
Result:='*';
|
|
Result:='*';
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TSQLDBRestDispatcher.HandleCORSRequest(aConnection : TSQLDBRestConnection; IO : TRestIO);
|
|
|
|
|
|
+procedure TSQLDBRestDispatcher.HandleCORSRequest(aConnection : TSQLDBConnectionDef; IO : TRestIO);
|
|
|
|
|
|
Var
|
|
Var
|
|
S : String;
|
|
S : String;
|
|
@@ -1720,7 +1828,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TSQLDBRestDispatcher.HandleResourceRequest(aConnection : TSQLDBRestConnection; IO : TRestIO);
|
|
|
|
|
|
+procedure TSQLDBRestDispatcher.HandleResourceRequest(aConnection : TSQLDBConnectionDef; IO : TRestIO);
|
|
|
|
|
|
Var
|
|
Var
|
|
Conn : TSQLConnection;
|
|
Conn : TSQLConnection;
|
|
@@ -1804,12 +1912,20 @@ begin
|
|
Result:=N;
|
|
Result:=N;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TSQLDBRestDispatcher.FindConnection(IO: TRestIO): TSQLDBRestConnection;
|
|
|
|
|
|
+function TSQLDBRestDispatcher.FindConnection(IO: TRestIO): TSQLDBConnectionDef;
|
|
|
|
+
|
|
|
|
+{
|
|
|
|
+ - Is a name given ? there a definition with the correct name in our connections:
|
|
|
|
+ Yes - Use that.
|
|
|
|
+ No - Check if connectionmanager has a connection with the name
|
|
|
|
+ - If the previous step didn't result in a connection
|
|
|
|
+}
|
|
|
|
|
|
Var
|
|
Var
|
|
N : UTF8String;
|
|
N : UTF8String;
|
|
|
|
|
|
begin
|
|
begin
|
|
|
|
+ Result:=Nil;
|
|
N:=GetConnectionName(IO);
|
|
N:=GetConnectionName(IO);
|
|
// If we have a name, look for it
|
|
// If we have a name, look for it
|
|
if (N<>'') then
|
|
if (N<>'') then
|
|
@@ -1817,16 +1933,40 @@ begin
|
|
Result:=Connections.FindConnection(N);
|
|
Result:=Connections.FindConnection(N);
|
|
if Assigned(Result) and not (Result.Enabled) then
|
|
if Assigned(Result) and not (Result.Enabled) then
|
|
Result:=Nil;
|
|
Result:=Nil;
|
|
|
|
+ If (Result=Nil) and (GetConnectionManager<>Nil) then
|
|
|
|
+ Result:=GetConnectionManager.Definitions.Find(N);
|
|
end
|
|
end
|
|
- else if Connections.Count=1 then
|
|
|
|
- Result:=Connections[0]
|
|
|
|
else
|
|
else
|
|
- Result:=Nil;
|
|
|
|
|
|
+ begin
|
|
|
|
+ if Connections.Count=1 then
|
|
|
|
+ begin
|
|
|
|
+ Result:=Connections[0];
|
|
|
|
+ If (Result=Nil) and (GetConnectionManager<>Nil) and (GetConnectionManager.Definitions.Count=1) then
|
|
|
|
+ Result:=GetConnectionManager.Definitions[0];
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TSQLDBRestDispatcher.GetConnectionManager: TSQLDBConnectionmanager;
|
|
|
|
+begin
|
|
|
|
+ if FConnectionManager=Nil then
|
|
|
|
+ begin
|
|
|
|
+ FConnectionManager:=CreateConnectionManager;
|
|
|
|
+ FConnectionManager.SetSubComponent(True);
|
|
|
|
+ FConnectionManager.OnLog:=@DoConnectionManagerLog;
|
|
|
|
+ end;
|
|
|
|
+ Result:=FConnectionManager;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TSQLDBRestDispatcher.CreateConnectionManager: TSQLDBConnectionmanager;
|
|
|
|
+begin
|
|
|
|
+ Result:=TSQLDBConnectionmanager.Create(Self);
|
|
|
|
+ Result.SetSubComponent(True);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TSQLDBRestDispatcher.CreateConnectionList: TSQLDBRestConnectionList;
|
|
function TSQLDBRestDispatcher.CreateConnectionList: TSQLDBRestConnectionList;
|
|
begin
|
|
begin
|
|
- Result:=TSQLDBRestConnectionList.Create(TSQLDBRestConnection);
|
|
|
|
|
|
+ Result:=TSQLDBRestConnectionList.Create(Self,TSQLDBRestConnection);
|
|
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1868,7 +2008,7 @@ var
|
|
ResourceName : UTF8String;
|
|
ResourceName : UTF8String;
|
|
Operation : TRestOperation;
|
|
Operation : TRestOperation;
|
|
Resource : TSQLDBRestResource;
|
|
Resource : TSQLDBRestResource;
|
|
- Connection : TSQLDBRestConnection;
|
|
|
|
|
|
+ Connection : TSQLDBConnectionDef;
|
|
|
|
|
|
begin
|
|
begin
|
|
Operation:=ExtractRestOperation(IO.Request);
|
|
Operation:=ExtractRestOperation(IO.Request);
|
|
@@ -2028,7 +2168,9 @@ begin
|
|
if Operation=opRemove then
|
|
if Operation=opRemove then
|
|
begin
|
|
begin
|
|
if AComponent=FAuthenticator then
|
|
if AComponent=FAuthenticator then
|
|
- FAuthenticator:=Nil
|
|
|
|
|
|
+ FAuthenticator:=Nil;
|
|
|
|
+ if FConnectionManager=aComponent then
|
|
|
|
+ FConnectionManager:=Nil;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -2248,9 +2390,7 @@ end;
|
|
function TSQLDBRestConnectionList.IndexOfConnection(const aName: UTF8string
|
|
function TSQLDBRestConnectionList.IndexOfConnection(const aName: UTF8string
|
|
): Integer;
|
|
): Integer;
|
|
begin
|
|
begin
|
|
- Result:=Count-1;
|
|
|
|
- While (Result>=0) and not SameText(GetConn(Result).Name,aName) do
|
|
|
|
- Dec(Result);
|
|
|
|
|
|
+ Result:=IndexOf(aName);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TSQLDBRestConnectionList.FindConnection(const aName: UTF8string): TSQLDBRestConnection;
|
|
function TSQLDBRestConnectionList.FindConnection(const aName: UTF8string): TSQLDBRestConnection;
|
|
@@ -2380,16 +2520,6 @@ end;
|
|
|
|
|
|
{ TSQLDBRestConnection }
|
|
{ TSQLDBRestConnection }
|
|
|
|
|
|
-procedure TSQLDBRestConnection.SetParams(AValue: TStrings);
|
|
|
|
-begin
|
|
|
|
- if FParams=AValue then Exit;
|
|
|
|
- FParams.Assign(AValue);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-function TSQLDBRestConnection.GetDisplayName: string;
|
|
|
|
-begin
|
|
|
|
- Result:=Name;
|
|
|
|
-end;
|
|
|
|
|
|
|
|
procedure TSQLDBRestConnection.SetConnection(AValue: TSQLConnection);
|
|
procedure TSQLDBRestConnection.SetConnection(AValue: TSQLConnection);
|
|
begin
|
|
begin
|
|
@@ -2403,7 +2533,7 @@ end;
|
|
|
|
|
|
function TSQLDBRestConnection.GetName: UTF8String;
|
|
function TSQLDBRestConnection.GetName: UTF8String;
|
|
begin
|
|
begin
|
|
- Result:=FName;
|
|
|
|
|
|
+ Result:=Inherited GetName;
|
|
if (Result='') and Assigned(SingleConnection) then
|
|
if (Result='') and Assigned(SingleConnection) then
|
|
Result:=SingleConnection.Name;
|
|
Result:=SingleConnection.Name;
|
|
if (Result='') then
|
|
if (Result='') then
|
|
@@ -2413,7 +2543,6 @@ end;
|
|
constructor TSQLDBRestConnection.Create(ACollection: TCollection);
|
|
constructor TSQLDBRestConnection.Create(ACollection: TCollection);
|
|
begin
|
|
begin
|
|
inherited Create(ACollection);
|
|
inherited Create(ACollection);
|
|
- FParams:=TStringList.Create;
|
|
|
|
FNotifier:=TConnectionFreeNotifier.Create(Nil);
|
|
FNotifier:=TConnectionFreeNotifier.Create(Nil);
|
|
TConnectionFreeNotifier(FNotifier).FRef:=Self;
|
|
TConnectionFreeNotifier(FNotifier).FRef:=Self;
|
|
FEnabled:=True;
|
|
FEnabled:=True;
|
|
@@ -2423,45 +2552,23 @@ destructor TSQLDBRestConnection.Destroy;
|
|
begin
|
|
begin
|
|
TConnectionFreeNotifier(FNotifier).FRef:=Nil;
|
|
TConnectionFreeNotifier(FNotifier).FRef:=Nil;
|
|
FreeAndNil(FNotifier);
|
|
FreeAndNil(FNotifier);
|
|
- FreeAndNil(FParams);
|
|
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TSQLDBRestConnection.Assign(Source: TPersistent);
|
|
procedure TSQLDBRestConnection.Assign(Source: TPersistent);
|
|
|
|
|
|
Var
|
|
Var
|
|
- C : TSQLDBRestConnection;
|
|
|
|
|
|
+ C : TSQLDBRestConnection absolute source;
|
|
|
|
|
|
begin
|
|
begin
|
|
if (Source is TSQLDBRestConnection) then
|
|
if (Source is TSQLDBRestConnection) then
|
|
- begin
|
|
|
|
- C:=Source as TSQLDBRestConnection;
|
|
|
|
- Password:=C.Password;
|
|
|
|
- UserName:=C.UserName;
|
|
|
|
- CharSet :=C.CharSet;
|
|
|
|
- HostName:=C.HostName;
|
|
|
|
- Role:=C.Role;
|
|
|
|
- DatabaseName:=C.DatabaseName;
|
|
|
|
- ConnectionType:=C.ConnectionType;
|
|
|
|
- Port:=C.Port;
|
|
|
|
- Name:=C.Name;
|
|
|
|
SchemaName:=C.SchemaName;
|
|
SchemaName:=C.SchemaName;
|
|
- Params.Assign(C.Params);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- inherited Assign(Source);
|
|
|
|
|
|
+ inherited Assign(Source);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TSQLDBRestConnection.ConfigConnection(aConn: TSQLConnection);
|
|
procedure TSQLDBRestConnection.ConfigConnection(aConn: TSQLConnection);
|
|
begin
|
|
begin
|
|
- aConn.CharSet:=Self.CharSet;
|
|
|
|
- aConn.HostName:=Self.HostName;
|
|
|
|
- aConn.DatabaseName:=Self.DatabaseName;
|
|
|
|
- aConn.UserName:=Self.UserName;
|
|
|
|
- aConn.Password:=Self.Password;
|
|
|
|
- aConn.Params:=Self.Params;
|
|
|
|
- if aConn is TSQLConnector then
|
|
|
|
- TSQLConnector(aConn).ConnectorType:=Self.ConnectionType;
|
|
|
|
|
|
+ Inherited AssignTo(aConn);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|