* Always reset FUpdateable when calling the SQLParser (+test)

git-svn-id: trunk@9878 -
This commit is contained in:
joost 2008-01-23 09:14:07 +00:00
parent ff4b5fcb59
commit ce9b080854
2 changed files with 25 additions and 4 deletions

View File

@ -997,6 +997,7 @@ begin
FWhereStopPos := 0; FWhereStopPos := 0;
ConnOptions := TSQLConnection(DataBase).ConnOptions; ConnOptions := TSQLConnection(DataBase).ConnOptions;
FUpdateable := False;
repeat repeat
begin begin
@ -1074,10 +1075,9 @@ begin
Setlength(FFromPart,StrLength); Setlength(FFromPart,StrLength);
Move(PStatementPart^,FFromPart[1],(StrLength)); Move(PStatementPart^,FFromPart[1],(StrLength));
FFrompart := trim(FFrompart); FFrompart := trim(FFrompart);
if ExtractStrings([',',' '],[],pchar(FFromPart),nil) > 1 then // select-statements from more then one table are not updateable
FUpdateable := False // select-statements from more then one table are not updateable if ExtractStrings([',',' '],[],pchar(FFromPart),nil) = 1 then
else
begin begin
FUpdateable := True; FUpdateable := True;
FTableName := FFromPart; FTableName := FFromPart;

View File

@ -26,6 +26,7 @@ type
procedure TearDown; override; procedure TearDown; override;
procedure RunTest; override; procedure RunTest; override;
published published
procedure TestClearUpdateableStatus;
procedure TestParseJoins; // bug 10148 procedure TestParseJoins; // bug 10148
procedure TestInsertLargeStrFields; // bug 9600 procedure TestInsertLargeStrFields; // bug 9600
procedure TestNumericNames; // Bug9661 procedure TestNumericNames; // Bug9661
@ -876,6 +877,26 @@ begin
inherited RunTest; inherited RunTest;
end; end;
procedure TTestFieldTypes.TestClearUpdateableStatus;
// Test if CanModify is correctly disabled in case of a select query without
// a from-statement.
begin
if not (SQLDbType in MySQLdbTypes) then Ignore('This test does only apply to MySQL because the used SQL-statement is MySQL only.');
with TSQLDBConnector(DBConnector) do
begin
with (GetNDataset(false,5) as TSQLQuery) do
begin
Open;
AssertEquals(True,CanModify);
Close;
SQL.Text:='select last_insert_id();';
Open;
AssertEquals(False,CanModify);
close;
end;
end;
end;
procedure TTestFieldTypes.TestParseJoins; procedure TTestFieldTypes.TestParseJoins;
begin begin
with TSQLDBConnector(DBConnector) do with TSQLDBConnector(DBConnector) do