* Implemented RowsAffected and modified the test

git-svn-id: trunk@9098 -
This commit is contained in:
joost 2007-11-03 11:12:01 +00:00
parent 515017ece6
commit 0fcf57fc1c
2 changed files with 19 additions and 2 deletions

View File

@ -42,6 +42,8 @@ type
TArrayStringArray = Array of TStringArray;
PArrayStringArray = ^TArrayStringArray;
{ TSQLite3Connection }
TSQLite3Connection = class(TSQLConnection)
private
fhandle: psqlite3;
@ -83,6 +85,7 @@ type
procedure execsql(const asql: string);
procedure UpdateIndexDefs(var IndexDefs : TIndexDefs; const TableName : string); // Differs from SQLDB.
function getprimarykeyfield(const atablename: string; const acursor: tsqlcursor): string;
function RowsAffected(cursor: TSQLCursor): TRowsCount; override;
public
function GetInsertID: int64;
published
@ -111,6 +114,8 @@ type
Procedure UnPrepare;
Procedure Execute;
Function Fetch : Boolean;
public
RowsAffected : Largeint;
end;
procedure freebindstring(astring: pointer); cdecl;
@ -222,6 +227,7 @@ begin
{$endif}
if (fstate<=sqliteerrormax) then
checkerror(sqlite3_reset(fstatement));
RowsAffected:=sqlite3_changes(fhandle);
if (fstate=sqlite_row) then
fstate:= sqliteerrormax; //first row
end;
@ -697,6 +703,14 @@ begin
end;
end;
function TSQLite3Connection.RowsAffected(cursor: TSQLCursor): TRowsCount;
begin
if assigned(cursor) then
Result := (cursor as TSQLite3Cursor).RowsAffected
else
Result := -1;
end;
procedure TSQLite3Connection.UpdateIndexDefs(var IndexDefs: TIndexDefs;
const TableName: string);
var

View File

@ -921,8 +921,11 @@ begin
Query.Open;
AssertTrue(query.RowsAffected<>0); // It should return -1 or the number of selected rows.
query.Close;
AssertEquals(-1,query.RowsAffected);
Query.SQL.Text := 'delete from FPDEV2';
AssertTrue(query.RowsAffected<>0); // It should return -1 or the same as the last time it was called.
if (SQLDbType = sqlite3) then // sqlite doesn't count the rowsaffected if there is no where-clause
Query.SQL.Text := 'delete from FPDEV2 where 1'
else
Query.SQL.Text := 'delete from FPDEV2';
Query.ExecSQL;
AssertEquals(2,query.RowsAffected);
Query.SQL.Text := 'delete from FPDEV2';