Hello, source-owners [?] I''ve made a change in the *CreateTable* method of the *TCustomSqliteDataset *class to include the *AutoInc *field type working ok. The current implementation don't of the type ftAutoInc doesn't work.
This is the source on the file *CustomSQLiteDS.pas*
*
*
*Could this be updated in the sources?*
*
*
*Thanks.
*
function TCustomSqliteDataset.CreateTable(const ATableName: String):
Boolean;
var
SQLTemp: String;
i, StrSize: Integer;
begin
{$ifdef DEBUG_SQLITEDS}
WriteLn('##TCustomSqliteDataset.CreateTable##');
if ATableName = '' then
WriteLn(' TableName Not Set');
if FieldDefs.Count = 0 then
WriteLn(' FieldDefs Not Initialized');
{$endif}
if (ATableName <> '') and (FieldDefs.Count > 0) then
begin
SQLTemp := 'CREATE TABLE ' + ATableName + ' (';
for i := 0 to FieldDefs.Count - 1 do
begin
//todo: add index to autoinc field
SQLTemp := SQLTemp + FieldDefs[i].Name;
case FieldDefs[i].DataType of
ftInteger:
SQLTemp := SQLTemp + ' INTEGER';
ftString:
begin
StrSize := FieldDefs[i].Size;
if StrSize = 0 then
StrSize := DefaultStringSize;
SQLTemp := SQLTemp + ' VARCHAR(' + IntToStr(StrSize) + ')';
end;
ftBoolean:
SQLTemp := SQLTemp + ' BOOL_INT';
ftFloat:
SQLTemp := SQLTemp + ' FLOAT';
ftWord:
SQLTemp := SQLTemp + ' WORD';
ftDateTime:
SQLTemp := SQLTemp + ' DATETIME';
ftDate:
SQLTemp := SQLTemp + ' DATE';
ftTime:
SQLTemp := SQLTemp + ' TIME';
ftLargeInt:
SQLTemp := SQLTemp + ' LARGEINT';
ftCurrency:
SQLTemp := SQLTemp + ' CURRENCY';
ftAutoInc:
SQLTemp := SQLTemp + ' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT';
ftMemo:
SQLTemp := SQLTemp + ' TEXT';
else
DatabaseError('Field type "' + FieldTypeNames[FieldDefs[i].DataType]
+
'" not supported', Self);
end;
if (UpperCase(FieldDefs[i].Name) = UpperCase(FPrimaryKey)) and
(FieldDefs[i].DataType<>ftAutoInc) then
SQLTemp := SQLTemp + ' PRIMARY KEY';
if i <> FieldDefs.Count - 1 then
SQLTemp := SQLTemp + ' , ';
end;
SQLTemp := SQLTemp + ');';
{$ifdef DEBUG_SQLITEDS}
WriteLn(' SQL: ',SqlTemp);
{$endif}
ExecSQL(SQLTemp);
Result := FReturnCode = SQLITE_OK;
end
else
Result := False;
end;
--
Timeo hominem unius libri
Cogito ergo sum - Carpe diem
[]s
Guionardo Furlan
http://guionardo.blogspot.com
http://www.guionardofurlan.com.br
<<330.gif>>
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
