* test for datetime params + fixes some minor cross-database specific things

patch by Lacak2, mantis #19878

git-svn-id: trunk@18152 -
This commit is contained in:
marco 2011-08-09 13:08:52 +00:00
parent abd5ca46c8
commit f22ec8545f
3 changed files with 32 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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');