Hi Luiz,

first of all, thanks a lot for the good job you did with sqlite for us all!

> > So, now my app can understand a timestamp field as a TDateTime instead
> > of a string...
>> ..
>>[removed]
>>...
>
> Here's how sqlite works (for good and bad):
>
> - You can create tables with any "field type": TIMESTAMP, TIME_STAMP,
> QWERTY etc
> - In any of this "field type" you can store anything: a integer, a
> float, a string
>
> Many sqlite managers make assumptions (each one create its own
> ..
>[removed]
>...

I'm perfectly aware of that and I'm living happily with it...it's an
embedded database anyway!

I don't expect a QWERTY type to be understood, of course, but I
thought a timestamp might, because the sqlite.org documentation
http://www.sqlite.org/lang_createtable.html
refers to it. And SQLiteAdmin and SQLite Manager and SQLite Firefox
extension can understand it.
Anyway, as you said, it is opensource and with a very open license, so
I just added the three lines of code I needed: my post number 1) is
just to share it.
The code needed is only:

Index: sqlite3ds.pas
===================================================================
--- sqlite3ds.pas       (revision 100)
+++ sqlite3ds.pas       (working copy)
@@ -165,6 +165,10 @@
    begin
      AType:= ftTime;
      FieldSize:=SizeOf(TDateTime);
+   end else if (ColumnStr = 'TIMESTAMP') then
+   begin
+     AType:= ftDateTime;
+     FieldSize:=SizeOf(TDateTime);
    end else if (ColumnStr = 'TEXT') then
    begin
      AType:= ftMemo;

It's not expensive from the point of view of the code performance nor
lightweight.
Even better, one could also assign AType := ftTimeStamp (which is
alreay defined in db.pas) and then change also db.pas accordingly:

Index: db.pas
===================================================================
--- db.pas      (revision 101)
+++ db.pas      (working copy)
@@ -1900,7 +1900,7 @@
       { ftInterface} Nil,
       { ftIDispatch} Nil,
       { ftGuid} TGuidField,
-      { ftTimeStamp} Nil,
+      { ftTimeStamp} TDateTimeField,
       { ftFMTBcd} Nil,
       { ftFixedWideString} TWideStringField,
       { ftWideMemo} TWideMemoField


I haven't seen the source code of the tools I mentioned above, but I
guess that sqlite3ds would behave in the same way if you change the
IFs like:
       if (ColumnStr = 'TIME')
into
       if ( Pos('TIME',ColumnStr) > 0 )
which is similar to what you do with BOOL, except that >0 understands
the CURRENT_TIME type that you can find in the documentation of sqlite

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to