Sfoglia il codice sorgente

--- Merging r18085 into '.':
U packages/fcl-db/src/base/db.pas
U packages/fcl-db/src/base/fields.inc
--- Merging r18088 into '.':
U packages/fcl-db/src/sqldb/postgres/pqconnection.pp
--- Merging r18099 into '.':
U packages/fcl-db/src/base/dataset.inc
G packages/fcl-db/src/base/db.pas
--- Merging r18108 into '.':
G packages/fcl-db/src/sqldb/postgres/pqconnection.pp
--- Merging r18127 into '.':
U packages/fcl-db/src/sqldb/oracle/oracleconnection.pp
--- Merging r18137 into '.':
U packages/fcl-db/src/sqldb/odbc/odbcconn.pas
--- Merging r18140 into '.':
G packages/fcl-db/src/base/fields.inc
--- Merging r18152 into '.':
U packages/fcl-db/tests/toolsunit.pas
U packages/fcl-db/tests/testfieldtypes.pas
U packages/fcl-db/tests/sqldbtoolsunit.pas
--- Merging r18156 into '.':
U packages/fcl-db/src/sqldb/examples/cfilltable.pp
U packages/fcl-db/src/sqldb/examples/sqldbexampleunit.pp
U packages/fcl-db/src/sqldb/examples/database.ini
U packages/fcl-db/src/sqldb/examples/alisttables.pp
U packages/fcl-db/src/sqldb/examples/readme.txt
--- Merging r18157 into '.':
G packages/fcl-db/src/base/fields.inc

# revisions: 18085,18088,18099,18108,18127,18137,18140,18152,18156,18157
------------------------------------------------------------------------
r18085 | marco | 2011-08-03 22:49:56 +0200 (Wed, 03 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/base/db.pas
M /trunk/packages/fcl-db/src/base/fields.inc

* TNumericField.SetAsboolean Mantis 18765

------------------------------------------------------------------------
------------------------------------------------------------------------
r18088 | marco | 2011-08-04 00:09:30 +0200 (Thu, 04 Aug 2011) | 3 lines
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/postgres/pqconnection.pp

* Map text to ftmemo(binary) instead of ftblob
Patch by Lacak2, mantis 19876

------------------------------------------------------------------------
------------------------------------------------------------------------
r18099 | marco | 2011-08-05 14:27:42 +0200 (Fri, 05 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/base/dataset.inc
M /trunk/packages/fcl-db/src/base/db.pas

* TDataset.BlockReadSize, patch by Luiz, mantis 19897 (library part. test in that report not included)

------------------------------------------------------------------------
------------------------------------------------------------------------
r18108 | marco | 2011-08-06 13:38:55 +0200 (Sat, 06 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/postgres/pqconnection.pp

* Mantis #19567: PostgreSQL TIME datatype fix by Lacak2. milliseconds and not correcting fttime fields with epoch.

------------------------------------------------------------------------
------------------------------------------------------------------------
r18127 | marco | 2011-08-07 00:51:35 +0200 (Sun, 07 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/oracle/oracleconnection.pp

* Initial implementation rowsaffected for Oracle. Patch from mantis #16885

------------------------------------------------------------------------
------------------------------------------------------------------------
r18137 | marco | 2011-08-07 15:39:20 +0200 (Sun, 07 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/odbc/odbcconn.pas

* columnsize overrides as per ODBC spec, Mantis #19775 patch by Lacak2

------------------------------------------------------------------------
------------------------------------------------------------------------
r18140 | marco | 2011-08-07 20:17:56 +0200 (Sun, 07 Aug 2011) | 3 lines
Changed paths:
M /trunk/packages/fcl-db/src/base/fields.inc

* provide terminating #0's to wide and stringfields, Patch from Ludo Brands
Mantis 199222

------------------------------------------------------------------------
------------------------------------------------------------------------
r18152 | marco | 2011-08-09 15:08:52 +0200 (Tue, 09 Aug 2011) | 3 lines
Changed paths:
M /trunk/packages/fcl-db/tests/sqldbtoolsunit.pas
M /trunk/packages/fcl-db/tests/testfieldtypes.pas
M /trunk/packages/fcl-db/tests/toolsunit.pas

* test for datetime params + fixes some minor cross-database specific things
patch by Lacak2, mantis #19878

------------------------------------------------------------------------
------------------------------------------------------------------------
r18156 | marco | 2011-08-09 18:42:39 +0200 (Tue, 09 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/sqldb/examples/alisttables.pp
M /trunk/packages/fcl-db/src/sqldb/examples/cfilltable.pp
M /trunk/packages/fcl-db/src/sqldb/examples/database.ini
M /trunk/packages/fcl-db/src/sqldb/examples/readme.txt
M /trunk/packages/fcl-db/src/sqldb/examples/sqldbexampleunit.pp

* Most sqldb example fixes from Mantis #17292.

------------------------------------------------------------------------
------------------------------------------------------------------------
r18157 | marco | 2011-08-09 21:13:27 +0200 (Tue, 09 Aug 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-db/src/base/fields.inc

* changed open to .first, mantis #19360

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_6@18860 -

marco 14 anni fa
parent
commit
386b6c290f

+ 19 - 1
packages/fcl-db/src/base/dataset.inc

@@ -257,7 +257,7 @@ begin
     deLayoutChange  : FEnableControlsEvent:=deLayoutChange;    
   end;
 
-  if not ControlsDisabled then begin
+  if not ControlsDisabled and (FState <> dsBlockRead) then begin
     for i := 0 to FDataSources.Count - 1 do
       TDataSource(FDataSources[i]).ProcessEvent(Event, Info);
   end;
@@ -864,6 +864,24 @@ begin
     end;
 end;
 
+procedure TDataSet.SetBlockReadSize(AValue: Integer);
+begin
+  // the state is changed even when setting the same BlockReadSize (follows Delphi behavior)
+  // e.g., state is dsBrowse and BlockReadSize is 1. Setting BlockReadSize to 1 will change state to dsBlockRead
+  FBlockReadSize := AValue;
+  if AValue > 0 then
+  begin
+    CheckActive; 
+    SetState(dsBlockRead);
+  end	
+  else
+  begin
+    //update state only when in dsBlockRead 
+    if FState = dsBlockRead then
+      SetState(dsBrowse);
+  end;	
+end;
+
 Procedure TDataSet.SetFieldDefs(AFieldDefs: TFieldDefs);
 
 begin

+ 5 - 1
packages/fcl-db/src/base/db.pas

@@ -514,7 +514,8 @@ type
     procedure RangeError(AValue, Min, Max: Double);
     procedure SetDisplayFormat(const AValue: string);
     procedure SetEditFormat(const AValue: string);
-    function GetAsBoolean: Boolean; override;
+    function  GetAsBoolean: Boolean; override;
+    Procedure SetAsBoolean(AValue: Boolean); override;
   public
     constructor Create(AOwner: TComponent); override;
   published
@@ -1342,6 +1343,7 @@ type
     FBeforeRefresh: TDataSetNotifyEvent;
     FBeforeScroll: TDataSetNotifyEvent;
     FBlobFieldCount: Longint;
+    FBlockReadSize: Integer;
     FBookmarkSize: Longint;
     FBuffers : TBufferArray;
     FBufferCount: Longint;
@@ -1386,6 +1388,7 @@ type
     Function GetActive : boolean;
     Procedure UnRegisterDataSource(ADatasource : TDatasource);
     Procedure UpdateFieldDefs;
+    procedure SetBlockReadSize(AValue: Integer);
     Procedure SetFieldDefs(AFieldDefs: TFieldDefs);
     procedure DoInsertAppendRecord(const Values: array of const; DoAppend : boolean);
   protected
@@ -1590,6 +1593,7 @@ type
     procedure UpdateCursorPos;
     procedure UpdateRecord;
     function UpdateStatus: TUpdateStatus; virtual;
+    property BlockReadSize: Integer read FBlockReadSize write SetBlockReadSize;
     property BOF: Boolean read FBOF;
     property Bookmark: TBookmarkStr read GetBookmarkStr write SetBookmarkStr;
     property CanModify: Boolean read GetCanModify;

+ 13 - 1
packages/fcl-db/src/base/fields.inc

@@ -709,7 +709,7 @@ begin
 
     FLookupDataSet.DisableControls;
     try
-      FLookupDataSet.Open;
+      FLookupDataSet.First;
       repeat
         FLookupList.Add(FLookupDataSet.FieldValues[FLookupKeyfields], FLookupDataSet.FieldValues[FLookupResultField]);
         FLookupDataSet.Next;
@@ -1102,6 +1102,7 @@ begin
   if DataSize <= dsMaxStringSize then
     begin
     Result:=GetData(@Buf);
+    buf[Size]:=#0;  //limit string to Size
     If Result then
       begin
       if transliterate then
@@ -1117,6 +1118,7 @@ begin
     begin
     SetLength(DynBuf,DataSize);
     Result:=GetData(@DynBuf[0]);
+    Dynbuf[Size]:=#0;  //limit string to Size
     If Result then
       begin
       if transliterate then
@@ -1223,11 +1225,13 @@ var
 begin
   if DataSize <= dsMaxStringSize then begin
     Result := GetData(@FixBuffer, False);
+    FixBuffer[Size]:=#0;     //limit string to Size
     aValue := FixBuffer;
   end else begin
     SetLength(DynBuffer, Succ(Size));
     Buffer := PWideChar(DynBuffer);
     Result := GetData(Buffer, False);
+    Buffer[Size]:=#0;     //limit string to Size
     if Result then
       aValue := Buffer;
   end;
@@ -1336,6 +1340,14 @@ begin
   Result:=GetAsInteger<>0;
 end;
 
+procedure TNumericField.SetAsBoolean(AValue: Boolean);
+begin
+  if AValue then
+    SetAsLongint(1)
+  else
+    SetAsLongint(0);
+end; 
+
 { ---------------------------------------------------------------------
     TLongintField
   ---------------------------------------------------------------------}

+ 6 - 4
packages/fcl-db/src/sqldb/examples/alisttables.pp

@@ -36,10 +36,12 @@ begin
 
   with Fconnection do
     begin
-    DatabaseName := dbname;
-    UserName := dbuser;
-    Password := dbpassword;
-    open;
+      if dbhost<>'' then
+        hostname:=dbhost;
+      DatabaseName := dbname;
+      UserName := dbuser;
+      Password := dbpassword;
+      open;
     end;
 
 // create FTransaction

+ 1 - 0
packages/fcl-db/src/sqldb/examples/cfilltable.pp

@@ -45,6 +45,7 @@ begin
     SQL.Add('  1,                         ');
     SQL.Add('  ''Florian Klaempfl'',      ');
     SQL.Add('  ''[email protected]'',');
+// Please update the date format according to your database (ie. MySQL 1975-1-1)
     SQL.Add('  ''1-jan-1975''               ');
     SQL.Add(')                            ');
 

+ 6 - 0
packages/fcl-db/src/sqldb/examples/database.ini

@@ -11,6 +11,12 @@
 
 type=interbase
 
+# host
+# gives optionally the server name or IP that should be used. 
+# do not specify if not used with some databases (Interbase)
+
+# host=127.0.0.1
+
 # name
 # gives the name of the database that should be used.
 # This could be a file-name or an alias, dependent on which database-engine is

+ 3 - 2
packages/fcl-db/src/sqldb/examples/readme.txt

@@ -3,8 +3,9 @@ In this directory you can find some examples for SQLdb. They can also be used
 to test functionality and new connections.
 
 To use these examples you need a working login to a DB-Server and have the
-appropiate client installed. You have to change 'database.ini' to work with the
-right database-engine and login-credentials.
+appropiate client installed.  You have to change 'database.ini' to work with
+the right database-engine and login-credentials.  Also check if the format
+of various dates matches the format your db expects.
 
 You can check if everything works fine by compiling & running 'alisttables'. If
 everything works well, you'll get a list of all tables in the database provided

+ 7 - 9
packages/fcl-db/src/sqldb/examples/sqldbexampleunit.pp

@@ -22,6 +22,7 @@ uses
 var dbtype,
     dbname,
     dbuser,
+    dbhost,
     dbpassword   : string;
 
     Fconnection  : tSQLConnection;
@@ -65,23 +66,18 @@ end;
 procedure ReadIniFile;
 
 var IniFile : TIniFile;
-
+    I : integer;
 begin
   IniFile := TIniFile.Create('database.ini');
   dbtype := IniFile.ReadString('Database','Type','');
+  dbhost := IniFile.ReadString('Database','Host','');
   dbname := IniFile.ReadString('Database','Name','');
   dbuser := IniFile.ReadString('Database','User','');
   dbpassword := IniFile.ReadString('Database','Password','');
   IniFile.Free;
   
-  FPdevBirthDates[1] := StrToDate('1-1-1991');
-  FPdevBirthDates[2] := StrToDate('2-2-1992');
-  FPdevBirthDates[3] := StrToDate('3-3-1993');
-  FPdevBirthDates[4] := StrToDate('4-4-1994');
-  FPdevBirthDates[5] := StrToDate('5-5-1995');
-  FPdevBirthDates[6] := StrToDate('6-6-1996');
-  FPdevBirthDates[7] := StrToDate('7-7-1997');
-  FPdevBirthDates[8] := StrToDate('8-8-1998');
+  For I:=1 to 8 do
+    FPdevBirthDates[i] := EncodeDate(1990+i,i,i);
 end;
 
 procedure CreateFConnection;
@@ -99,6 +95,8 @@ begin
 
   with Fconnection do
     begin
+    if dbhost<>'' then
+      Hostname:=dbhost;
     DatabaseName := dbname;
     UserName := dbuser;
     Password := dbpassword;

+ 3 - 3
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -419,7 +419,7 @@ begin
           Size:=SizeOf(DateVal);
           CType:=SQL_C_TYPE_DATE;
           SqlType:=SQL_TYPE_DATE;
-          ColumnSize:=Size;
+          ColumnSize:=10;
         end;
       ftTime:
         begin
@@ -428,7 +428,7 @@ begin
           Size:=SizeOf(TimeVal);
           CType:=SQL_C_TYPE_TIME;
           SqlType:=SQL_TYPE_TIME;
-          ColumnSize:=Size;
+          ColumnSize:=12;
         end;
       ftDateTime:
         begin
@@ -437,7 +437,7 @@ begin
           Size:=SizeOf(TimeStampVal);
           CType:=SQL_C_TYPE_TIMESTAMP;
           SqlType:=SQL_TYPE_TIMESTAMP;
-          ColumnSize:=Size;
+          ColumnSize:=23;
         end;
       ftBoolean:
         begin

+ 10 - 0
packages/fcl-db/src/sqldb/oracle/oracleconnection.pp

@@ -77,6 +77,7 @@ type
     procedure RollbackRetaining(trans:TSQLHandle); override;
     // - Statement execution
     procedure Execute(cursor:TSQLCursor; ATransaction:TSQLTransaction; AParams:TParams); override;
+    function RowsAffected(cursor: TSQLCursor): TRowsCount; override;
     // - Result retrieving
     procedure AddFieldDefs(cursor:TSQLCursor; FieldDefs:TFieldDefs); override;
     function Fetch(cursor:TSQLCursor):boolean; override;
@@ -439,6 +440,15 @@ begin
     end;
 end;
 
+function TOracleConnection.RowsAffected(cursor: TSQLCursor): TRowsCount;
+var rowcount: ub4;
+begin
+  if OCIAttrGet((cursor as TOracleCursor).FOciStmt, OCI_HTYPE_STMT, @rowcount, nil, OCI_ATTR_ROW_COUNT, FOciError) = OCI_SUCCESS then
+    Result:=rowcount
+  else
+    Result:=inherited RowsAffected(cursor);
+end;
+
 procedure TOracleConnection.AddFieldDefs(cursor: TSQLCursor; FieldDefs: TFieldDefs);
 
 var Param      : POCIParam;

+ 11 - 8
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -402,7 +402,7 @@ begin
                              if size > dsMaxStringSize then size := dsMaxStringSize;
                              end;
 //    Oid_text               : Result := ftstring;
-    Oid_text               : Result := ftBlob;
+    Oid_text               : Result := ftMemo;
     Oid_Bytea              : Result := ftBlob;
     Oid_oid                : Result := ftInteger;
     Oid_int8               : Result := ftLargeInt;
@@ -601,11 +601,11 @@ begin
           begin
           case AParams[i].DataType of
             ftDateTime:
-              s := FormatDateTime('yyyy-mm-dd hh:nn:ss', AParams[i].AsDateTime);
+              s := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', AParams[i].AsDateTime);
             ftDate:
               s := FormatDateTime('yyyy-mm-dd', AParams[i].AsDateTime);
             ftTime:
-              s := FormatDateTime('hh:nn:ss', AParams[i].AsDateTime);
+              s := FormatDateTime('hh:nn:ss.zzz', AParams[i].AsDateTime);
             ftFloat, ftBCD:
               Str(AParams[i].AsFloat, s);
             ftCurrency:
@@ -620,7 +620,7 @@ begin
           GetMem(ar[i],length(s)+1);
           StrMove(PChar(ar[i]),Pchar(s),Length(S)+1);
           lengths[i]:=Length(s);
-          if (AParams[i].DataType in [ftBlob,ftGraphic,ftCurrency]) then
+          if (AParams[i].DataType in [ftBlob,ftMemo,ftGraphic,ftCurrency]) then
             Formats[i]:=1
           else
             Formats[i]:=0;  
@@ -771,18 +771,21 @@ begin
           Move(CurrBuff^, Buffer^, li);
           pchar(Buffer + li)^ := #0;
           end;
-        ftBlob : Createblob := True;
-        ftdate :
+        ftBlob, ftMemo :
+          CreateBlob := True;
+        ftDate :
           begin
           dbl := pointer(buffer);
           dbl^ := BEtoN(plongint(CurrBuff)^) + 36526;
           end;
-        ftDateTime, fttime :
+        ftDateTime, ftTime :
           begin
           pint64(buffer)^ := BEtoN(pint64(CurrBuff)^);
           dbl := pointer(buffer);
           if FIntegerDatetimes then dbl^ := pint64(buffer)^/1000000;
-          dbl^ := (dbl^+3.1558464E+009)/86400;  // postgres counts seconds elapsed since 1-1-2000
+          if FieldDef.DataType = ftDateTime then
+            dbl^ := dbl^ + 3.1558464E+009; // postgres counts seconds elapsed since 1-1-2000
+          dbl^ := dbl^ / 86400;
           // Now convert the mathematically-correct datetime to the
           // illogical windows/delphi/fpc TDateTime:
           if (dbl^ <= 0) and (frac(dbl^)<0) then

+ 4 - 2
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -137,7 +137,7 @@ begin
     begin
     Fconnection := tPQConnection.Create(nil);
     FieldtypeDefinitions[ftCurrency] := 'MONEY';
-    FieldtypeDefinitions[ftBlob] := 'TEXT';
+    FieldtypeDefinitions[ftBlob] := 'BYTEA';
     FieldtypeDefinitions[ftMemo] := 'TEXT';
     FieldtypeDefinitions[ftGraphic] := '';
     end;
@@ -152,12 +152,14 @@ begin
 
   if SQLDbType in [mysql40,mysql41,mysql50,mysql51,odbc,interbase] then
     begin
-    // Some DB's do not support milliseconds in time-fields.
+    // Some DB's do not support milliseconds in datetime and time fields.
     // Firebird support miliseconds, see BUG 17199 (when resolved, then interbase can be excluded)
     for t := 0 to testValuesCount-1 do
       begin
       testTimeValues[t] := copy(testTimeValues[t],1,8)+'.000';
       testValues[ftTime,t] := copy(testTimeValues[t],1,8)+'.000';
+      if length(testValues[ftDateTime,t]) > 19 then
+        testValues[ftDateTime,t] := copy(testValues[ftDateTime,t],1,19)+'.000';
       end;
     end;
   if SQLDbType in [postgresql,interbase] then

+ 21 - 9
packages/fcl-db/tests/testfieldtypes.pas

@@ -88,6 +88,7 @@ type
     procedure TestDateParamQuery;
     procedure TestIntParamQuery;
     procedure TestTimeParamQuery;
+    procedure TestDateTimeParamQuery;
     procedure TestFmtBCDParamQuery;
     procedure TestFloatParamQuery;
     procedure TestBCDParamQuery;
@@ -740,6 +741,11 @@ begin
   TestXXParamQuery(ftTime,FieldtypeDefinitionsConst[ftTime],testValuesCount);
 end;
 
+procedure TTestFieldTypes.TestDateTimeParamQuery;
+begin
+  TestXXParamQuery(ftDateTime,FieldtypeDefinitions[ftDateTime],testValuesCount);
+end;
+
 procedure TTestFieldTypes.TestFloatParamQuery;
 
 begin
@@ -802,7 +808,8 @@ begin
         ftDate   : if cross then
                      Params.ParamByName('field1').AsString:= testDateValues[i]
                    else
-                     Params.ParamByName('field1').AsDateTime:= StrToDate(testDateValues[i],'yyyy/mm/dd','-');
+                     Params.ParamByName('field1').AsDate := StrToDate(testDateValues[i],'yyyy/mm/dd','-');
+        ftDateTime:Params.ParamByName('field1').AsDateTime := StrToDateTime(testValues[ADataType,i], DBConnector.FormatSettings);
         ftFMTBcd : Params.ParamByName('field1').AsFMTBCD:= StrToBCD(testFmtBCDValues[i],DBConnector.FormatSettings)
       else
         AssertTrue('no test for paramtype available',False);
@@ -825,7 +832,8 @@ begin
         ftFixedChar : AssertEquals(PadRight(testStringValues[i],10),FieldByName('FIELD1').AsString);
         ftString : AssertEquals(testStringValues[i],FieldByName('FIELD1').AsString);
         ftTime   : AssertEquals(testTimeValues[i],DateTimeToTimeString(FieldByName('FIELD1').AsDateTime));
-        ftdate   : AssertEquals(testDateValues[i],FormatDateTime('yyyy/mm/dd',FieldByName('FIELD1').AsDateTime, DBConnector.FormatSettings));
+        ftDate   : AssertEquals(testDateValues[i],DateTimeToStr(FieldByName('FIELD1').AsDateTime, DBConnector.FormatSettings));
+        ftDateTime : AssertEquals(testValues[ADataType,i], DateTimeToStr(FieldByName('FIELD1').AsDateTime, DBConnector.FormatSettings));
         ftFMTBcd : AssertEquals(testFmtBCDValues[i],BCDToStr(FieldByName('FIELD1').AsBCD,DBConnector.FormatSettings))
       else
         AssertTrue('no test for paramtype available',False);
@@ -1638,10 +1646,13 @@ procedure TTestFieldTypes.TestSQLClob;
   begin
     AssertEquals(testStringValues[a],AField.AsString);
   end;
+var datatype: string;
 begin
-  if SQLDbType=interbase then
-      Ignore('This test does not apply to Interbase/Firebird, since it does not support CLOB fields');
-  TestSQLFieldType(ftMemo, 'CLOB', 0, @TestSQLClob_GetSQLText, @CheckFieldValue);
+  if sqlDBType=sqlite3 then
+    datatype:='CLOB'
+  else
+    datatype:=FieldtypeDefinitions[ftMemo];
+  TestSQLFieldType(ftMemo, datatype, 0, @TestSQLClob_GetSQLText, @CheckFieldValue);
 end;
 
 // Placed here, as long as bug 18702 is not solved
@@ -1655,14 +1666,15 @@ procedure TTestFieldTypes.TestSQLLargeint;
   begin
     AssertEquals(testLargeIntValues[a],AField.AsLargeInt);
   end;
+var datatype: string;
 begin
-  if sqlDBType=interbase then
-    TestSQLFieldType(ftLargeint, 'BIGINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue)
+  if sqlDBType=sqlite3 then
+    datatype:='LARGEINT'
   else
-    TestSQLFieldType(ftLargeint, 'LARGEINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue);
+    datatype:='BIGINT';
+  TestSQLFieldType(ftLargeint, datatype, 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue);
 end;
 
-
 procedure TTestFieldTypes.TestUpdateIndexDefs;
 var ds : TSQLQuery;
 begin

+ 7 - 1
packages/fcl-db/tests/toolsunit.pas

@@ -220,6 +220,8 @@ begin
   FFormatSettings.ThousandSeparator:=#0;
   FFormatSettings.DateSeparator:='-';
   FFormatSettings.TimeSeparator:=':';
+  FFormatSettings.ShortDateFormat:='yyyy/mm/dd';
+  FFormatSettings.LongTimeFormat:='hh:nn:ss.zzz';
   FUsedDatasets := TFPList.Create;
   CreateFieldDataset;
   CreateNDatasets;
@@ -315,9 +317,13 @@ begin
     // The decimalseparator was set to a comma for currencies and to a dot for ftBCD values.
     // DecimalSeparator for PostgreSQL must correspond to monetary locale set on PostgreSQL server
     // Here we assume, that locale on client side is same as locale on server
-        
     testValues[ftCurrency,i] := CurrToStr(testCurrencyValues[i]);
     testValues[ftBCD,i] := CurrToStr(testCurrencyValues[i],FormatSettings);
+    // For date '0001-01-01' other time-part like '00:00:00' causes "Invalid variant type cast", because of < MinDateTime constant
+    if (testDateValues[i]>'0001-01-01') and (testTimeValues[i]>='00:00:01') and (testTimeValues[i]<'24:00:00') then
+      testValues[ftDateTime,i] := testDateValues[i] + ' ' + testTimeValues[i]
+    else
+      testValues[ftDateTime,i] := testDateValues[i];
     end;
 
   if dbconnectorname = '' then raise Exception.Create('There is no db-connector specified');