mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 11:09:42 +02:00
* Do not change SQL property value internally. Use instead a separated field (FEffectiveSQL)
git-svn-id: trunk@15686 -
This commit is contained in:
parent
79fa2eb539
commit
50861d26ab
@ -128,6 +128,7 @@ type
|
||||
FPrimaryKeyNo: Integer;
|
||||
FFileName: String;
|
||||
FSQL: String;
|
||||
FEffectiveSQL: String;
|
||||
FTableName: String;
|
||||
FSqlFilterTemplate: String;
|
||||
FAutoIncFieldNo: Integer;
|
||||
@ -924,8 +925,10 @@ begin
|
||||
begin
|
||||
if FTablename = '' then
|
||||
DatabaseError('Tablename not set', Self);
|
||||
FSQL := 'Select * from ' + FTableName + ';';
|
||||
end;
|
||||
FEffectiveSQL := 'Select * from ' + FTableName + ';';
|
||||
end
|
||||
else
|
||||
FEffectiveSQL := FSQL;
|
||||
|
||||
if FSqliteHandle = nil then
|
||||
GetSqliteHandle;
|
||||
@ -1218,7 +1221,7 @@ begin
|
||||
FSqlFilterTemplate := FSqlFilterTemplate + FieldDefs[FieldDefs.Count - 1].Name +
|
||||
' FROM ' + FTableName;
|
||||
end;
|
||||
//set FSQL considering MasterSource active record
|
||||
//set FEffectiveSQL considering MasterSource active record
|
||||
SetDetailFilter;
|
||||
end;
|
||||
|
||||
@ -1435,7 +1438,7 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
if (FMasterLink.Dataset.RecordCount = 0) or not FMasterLink.Active then //Retrieve all data
|
||||
FSQL := FSqlFilterTemplate
|
||||
FEffectiveSQL := FSqlFilterTemplate
|
||||
else
|
||||
begin
|
||||
AFilter := ' where ';
|
||||
@ -1445,7 +1448,7 @@ begin
|
||||
if i <> FMasterLink.Fields.Count - 1 then
|
||||
AFilter := AFilter + ' and ';
|
||||
end;
|
||||
FSQL := FSqlFilterTemplate + AFilter;
|
||||
FEffectiveSQL := FSqlFilterTemplate + AFilter;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1455,7 +1458,7 @@ begin
|
||||
{$ifdef DEBUG_SQLITEDS}
|
||||
WriteLn('##TCustomSqliteDataset.MasterChanged##');
|
||||
WriteLn(' SQL used to filter detail dataset:');
|
||||
WriteLn(' ', FSQL);
|
||||
WriteLn(' ', FEffectiveSQL);
|
||||
{$endif}
|
||||
RefetchData;
|
||||
end;
|
||||
@ -1537,8 +1540,7 @@ begin
|
||||
ExecSQL(SQLList);
|
||||
end;
|
||||
|
||||
function TCustomSqliteDataset.GetSQLValue(Values: PPChar; FieldIndex: Integer
|
||||
): String;
|
||||
function TCustomSqliteDataset.GetSQLValue(Values: PPChar; FieldIndex: Integer): String;
|
||||
begin
|
||||
if (State = dsInactive) or (FieldIndex < 0) or (FieldIndex >= FieldDefs.Count) then
|
||||
DatabaseError('Error retrieving SQL value: dataset inactive or field out of range', Self);
|
||||
|
@ -163,7 +163,7 @@ begin
|
||||
{$endif}
|
||||
FAutoIncFieldNo := -1;
|
||||
FieldDefs.Clear;
|
||||
FReturnCode := sqlite3_prepare(FSqliteHandle, PChar(FSQL), -1, @vm, nil);
|
||||
FReturnCode := sqlite3_prepare(FSqliteHandle, PChar(FEffectiveSQL), -1, @vm, nil);
|
||||
if FReturnCode <> SQLITE_OK then
|
||||
DatabaseError(ReturnString, Self);
|
||||
sqlite3_step(vm);
|
||||
@ -281,7 +281,7 @@ begin
|
||||
sqlite3_exec(FSqliteHandle, PChar('Select Max(' + Fields[FAutoIncFieldNo].FieldName +
|
||||
') from ' + FTableName), @GetAutoIncValue, @FNextAutoInc, nil);
|
||||
|
||||
FReturnCode := sqlite3_prepare(FSqliteHandle, PChar(FSQL), -1, @vm, nil);
|
||||
FReturnCode := sqlite3_prepare(FSqliteHandle, PChar(FEffectiveSQL), -1, @vm, nil);
|
||||
if FReturnCode <> SQLITE_OK then
|
||||
DatabaseError(ReturnString, Self);
|
||||
|
||||
|
@ -119,7 +119,7 @@ var
|
||||
begin
|
||||
FieldDefs.Clear;
|
||||
FAutoIncFieldNo := -1;
|
||||
FReturnCode := sqlite_compile(FSqliteHandle, PChar(FSQL), nil, @vm, nil);
|
||||
FReturnCode := sqlite_compile(FSqliteHandle, PChar(FEffectiveSQL), nil, @vm, nil);
|
||||
if FReturnCode <> SQLITE_OK then
|
||||
DatabaseError(ReturnString, Self);
|
||||
sqlite_step(vm, @ColumnCount, @ColumnValues, @ColumnNames);
|
||||
@ -231,7 +231,7 @@ begin
|
||||
sqlite_exec(FSqliteHandle, PChar('Select Max(' + Fields[FAutoIncFieldNo].FieldName + ') from ' + FTableName),
|
||||
@GetAutoIncValue, @FNextAutoInc, nil);
|
||||
|
||||
FReturnCode := sqlite_compile(FSqliteHandle, PChar(FSQL), nil, @vm, nil);
|
||||
FReturnCode := sqlite_compile(FSqliteHandle, PChar(FEffectiveSQL), nil, @vm, nil);
|
||||
if FReturnCode <> SQLITE_OK then
|
||||
DatabaseError(ReturnString, Self);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user