mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 23:00:13 +02:00
* Implemented CheckParams for TSQLStatement, TSQLQuery. It disables check for parameter names
git-svn-id: trunk@24705 -
This commit is contained in:
parent
54c7620793
commit
f58b3aa25a
@ -216,6 +216,7 @@ type
|
|||||||
|
|
||||||
TCustomSQLStatement = Class(TComponent)
|
TCustomSQLStatement = Class(TComponent)
|
||||||
Private
|
Private
|
||||||
|
FCheckParams: Boolean;
|
||||||
FCursor : TSQLCursor;
|
FCursor : TSQLCursor;
|
||||||
FDatabase: TSQLConnection;
|
FDatabase: TSQLConnection;
|
||||||
FParams: TParams;
|
FParams: TParams;
|
||||||
@ -248,6 +249,7 @@ type
|
|||||||
Property Params : TParams Read FParams Write SetParams;
|
Property Params : TParams Read FParams Write SetParams;
|
||||||
Property Datasource : TDatasource Read FDataSource Write SetDataSource;
|
Property Datasource : TDatasource Read FDataSource Write SetDataSource;
|
||||||
Property ParseSQL : Boolean Read FParseSQL Write FParseSQL;
|
Property ParseSQL : Boolean Read FParseSQL Write FParseSQL;
|
||||||
|
Property CheckParams : Boolean Read FCheckParams Write FCheckParams default true;
|
||||||
Public
|
Public
|
||||||
constructor Create(AOwner : TComponent); override;
|
constructor Create(AOwner : TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -266,12 +268,15 @@ type
|
|||||||
Property SQL;
|
Property SQL;
|
||||||
Property Params;
|
Property Params;
|
||||||
Property Datasource;
|
Property Datasource;
|
||||||
|
Property ParseSQL;
|
||||||
|
Property CheckParams;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCustomSQLQuery }
|
{ TCustomSQLQuery }
|
||||||
|
|
||||||
TCustomSQLQuery = class (TCustomBufDataset)
|
TCustomSQLQuery = class (TCustomBufDataset)
|
||||||
private
|
private
|
||||||
|
FCheckParams: Boolean;
|
||||||
FCursor : TSQLCursor;
|
FCursor : TSQLCursor;
|
||||||
FUpdateable : boolean;
|
FUpdateable : boolean;
|
||||||
FTableName : string;
|
FTableName : string;
|
||||||
@ -399,6 +404,7 @@ type
|
|||||||
property UsePrimaryKeyAsKey : boolean read FUsePrimaryKeyAsKey write SetUsePrimaryKeyAsKey default true;
|
property UsePrimaryKeyAsKey : boolean read FUsePrimaryKeyAsKey write SetUsePrimaryKeyAsKey default true;
|
||||||
property StatementType : TStatementType read GetStatementType;
|
property StatementType : TStatementType read GetStatementType;
|
||||||
property ParseSQL : Boolean read FParseSQL write SetParseSQL default true;
|
property ParseSQL : Boolean read FParseSQL write SetParseSQL default true;
|
||||||
|
Property CheckParams : Boolean Read FCheckParams Write FCheckParams default true;
|
||||||
Property DataSource : TDatasource Read GetDataSource Write SetDatasource;
|
Property DataSource : TDatasource Read GetDataSource Write SetDatasource;
|
||||||
property ServerFilter: string read FServerFilterText write SetServerFilterText;
|
property ServerFilter: string read FServerFilterText write SetServerFilterText;
|
||||||
property ServerFiltered: Boolean read FServerFiltered write SetServerFiltered default False;
|
property ServerFiltered: Boolean read FServerFiltered write SetServerFiltered default False;
|
||||||
@ -454,6 +460,7 @@ type
|
|||||||
property UpdateMode;
|
property UpdateMode;
|
||||||
property UsePrimaryKeyAsKey;
|
property UsePrimaryKeyAsKey;
|
||||||
property ParseSQL;
|
property ParseSQL;
|
||||||
|
Property CheckParams;
|
||||||
Property DataSource;
|
Property DataSource;
|
||||||
property ServerFilter;
|
property ServerFilter;
|
||||||
property ServerFiltered;
|
property ServerFiltered;
|
||||||
@ -617,6 +624,8 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
UnPrepare;
|
UnPrepare;
|
||||||
|
if not CheckParams then
|
||||||
|
exit;
|
||||||
if assigned(DataBase) then
|
if assigned(DataBase) then
|
||||||
ConnOptions:=DataBase.ConnOptions
|
ConnOptions:=DataBase.ConnOptions
|
||||||
else
|
else
|
||||||
@ -742,6 +751,8 @@ begin
|
|||||||
FSQL:=TStringList.Create;
|
FSQL:=TStringList.Create;
|
||||||
TStringList(FSQL).OnChange:=@OnChangeSQL;
|
TStringList(FSQL).OnChange:=@OnChangeSQL;
|
||||||
FParams:=CreateParams;
|
FParams:=CreateParams;
|
||||||
|
FCheckParams:=True;
|
||||||
|
FParseSQL:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCustomSQLStatement.Destroy;
|
destructor TCustomSQLStatement.Destroy;
|
||||||
@ -1275,7 +1286,7 @@ var ConnOptions : TConnOptions;
|
|||||||
begin
|
begin
|
||||||
UnPrepare;
|
UnPrepare;
|
||||||
FSchemaType:=stNoSchema;
|
FSchemaType:=stNoSchema;
|
||||||
if (FSQL <> nil) then
|
if (FSQL <> nil) and CheckParams then
|
||||||
begin
|
begin
|
||||||
if assigned(DataBase) then
|
if assigned(DataBase) then
|
||||||
ConnOptions := TSQLConnection(DataBase).ConnOptions
|
ConnOptions := TSQLConnection(DataBase).ConnOptions
|
||||||
@ -1295,7 +1306,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomSQLQuery.ParamByName(Const AParamName : String) : TParam;
|
function TCustomSQLQuery.ParamByName(const AParamName: String): TParam;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=Params.ParamByName(AParamName);
|
Result:=Params.ParamByName(AParamName);
|
||||||
@ -1307,7 +1318,7 @@ begin
|
|||||||
CheckInactive;
|
CheckInactive;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TCustomSQLQuery.SetTransaction(Value : TDBTransaction);
|
procedure TCustomSQLQuery.SetTransaction(Value: TDBTransaction);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
UnPrepare;
|
UnPrepare;
|
||||||
@ -1335,13 +1346,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomSQLQuery.IsPrepared : Boolean;
|
function TCustomSQLQuery.IsPrepared: Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := Assigned(FCursor) and FCursor.FPrepared;
|
Result := Assigned(FCursor) and FCursor.FPrepared;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomSQLQuery.AddFilter(SQLstr : string) : string;
|
function TCustomSQLQuery.AddFilter(SQLstr: string): string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (FWhereStartPos > 0) and (FWhereStopPos > 0) then
|
if (FWhereStartPos > 0) and (FWhereStopPos > 0) then
|
||||||
@ -1380,7 +1391,7 @@ begin
|
|||||||
First;
|
First;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TCustomSQLQuery.SetActive (Value : Boolean);
|
procedure TCustomSQLQuery.SetActive(Value: Boolean);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited SetActive(Value);
|
inherited SetActive(Value);
|
||||||
@ -1855,7 +1866,7 @@ begin
|
|||||||
FServerIndexDefs := TServerIndexDefs.Create(Self);
|
FServerIndexDefs := TServerIndexDefs.Create(Self);
|
||||||
|
|
||||||
FParseSQL := True;
|
FParseSQL := True;
|
||||||
|
CheckParams:=True;
|
||||||
FServerFiltered := False;
|
FServerFiltered := False;
|
||||||
FServerFilterText := '';
|
FServerFilterText := '';
|
||||||
|
|
||||||
@ -1925,7 +1936,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TCustomSQLQuery.UpdateServerIndexDefs;
|
procedure TCustomSQLQuery.UpdateServerIndexDefs;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FServerIndexDefs.Clear;
|
FServerIndexDefs.Clear;
|
||||||
@ -1933,7 +1944,7 @@ begin
|
|||||||
TSQLConnection(DataBase).UpdateIndexDefs(ServerIndexDefs,FTableName);
|
TSQLConnection(DataBase).UpdateIndexDefs(ServerIndexDefs,FTableName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TCustomSQLQuery.ApplyRecUpdate(UpdateKind : TUpdateKind);
|
procedure TCustomSQLQuery.ApplyRecUpdate(UpdateKind: TUpdateKind);
|
||||||
|
|
||||||
var FieldNamesQuoteChars : TQuoteChars;
|
var FieldNamesQuoteChars : TQuoteChars;
|
||||||
|
|
||||||
@ -2073,7 +2084,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function TCustomSQLQuery.GetCanModify: Boolean;
|
function TCustomSQLQuery.GetCanModify: Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// the test for assigned(FCursor) is needed for the case that the dataset isn't opened
|
// the test for assigned(FCursor) is needed for the case that the dataset isn't opened
|
||||||
@ -2152,7 +2163,7 @@ begin
|
|||||||
FInsertSQL.Assign(AValue);
|
FInsertSQL.Assign(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TCustomSQLQuery.SetDataSource(AValue : TDatasource);
|
procedure TCustomSQLQuery.SetDataSource(AValue: TDatasource);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
DS : TDatasource;
|
DS : TDatasource;
|
||||||
@ -2177,7 +2188,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TCustomSQLQuery.GetDataSource : TDatasource;
|
function TCustomSQLQuery.GetDataSource: TDatasource;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Assigned(FMasterLink) then
|
If Assigned(FMasterLink) then
|
||||||
|
Loading…
Reference in New Issue
Block a user