* Patch + test to map integer field with auto_increment property to ftautoinc

Mantis #21438, patch by Lacak2.

git-svn-id: trunk@20483 -
This commit is contained in:
marco 2012-03-08 19:57:20 +00:00
parent 3ebdd64d75
commit f5a4f6b4af
2 changed files with 47 additions and 2 deletions

View File

@ -567,7 +567,10 @@ begin
end;
FIELD_TYPE_LONG, FIELD_TYPE_INT24:
begin
NewType := ftInteger;
if AField^.flags and AUTO_INCREMENT_FLAG <> 0 then
NewType := ftAutoInc
else
NewType := ftInteger;
NewSize := 0;
end;
{$ifdef mysql50_up}

View File

@ -111,6 +111,7 @@ type
procedure TestSQLClob;
procedure TestSQLLargeint;
procedure TestSQLInterval;
procedure TestSQLIdentity;
end;
implementation
@ -158,6 +159,8 @@ const
'', #0, #0#1#2#3#4#5#6#7#8#9
);
STestNotApplicable = 'This test does not apply to this sqldb-connection type';
procedure TTestFieldTypes.TestpfInUpdateFlag;
var ds : TCustomBufDataset;
@ -1216,7 +1219,7 @@ end;
procedure TTestFieldTypes.TestInsertReturningQuery;
begin
if not(SQLDbType in [postgresql,interbase,oracle]) then Ignore('This test does not apply to this db-engine');
if not(SQLDbType in [postgresql,interbase,oracle]) then Ignore(STestNotApplicable);
with TSQLDBConnector(DBConnector) do
begin
// This only works with databases that supports 'insert into .. returning'
@ -1833,6 +1836,45 @@ begin
TestSQLFieldType(ftTime, datatype, sizeof(TDateTime), @TestSQLInterval_GetSQLText, @CheckFieldValue);
end;
procedure TTestFieldTypes.TestSQLIdentity;
var datatype, values: string;
fieldtype: TFieldType;
i: integer;
begin
if sqlDBType in MySQLdbTypes then
begin
datatype:='INT AUTO_INCREMENT PRIMARY KEY';
values:='VALUES(DEFAULT)';
fieldtype:=ftAutoInc;
end
else if sqlDBType = sqlite3 then
begin
datatype:='INTEGER PRIMARY KEY';
values:='DEFAULT VALUES';
fieldtype:=ftInteger;
end
else
Ignore(STestNotApplicable);
CreateTableWithFieldType(fieldtype, datatype);
TestFieldDeclaration(fieldtype, sizeof(longint));
for i := 1 to 3 do
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 '+values);
with TSQLDBConnector(DBConnector).Query do
begin
Open;
AssertTrue(Locate('FT',1,[])); // bug 17624
for i := 1 to 3 do
begin
AssertEquals(Fields[0].AsInteger, i);
Next;
end;
Close;
end;
end;
procedure TTestFieldTypes.TestUpdateIndexDefs;
var ds : TSQLQuery;
begin