* 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 begin
Fconnection := tPQConnection.Create(nil); Fconnection := tPQConnection.Create(nil);
FieldtypeDefinitions[ftCurrency] := 'MONEY'; FieldtypeDefinitions[ftCurrency] := 'MONEY';
FieldtypeDefinitions[ftBlob] := 'TEXT'; FieldtypeDefinitions[ftBlob] := 'BYTEA';
FieldtypeDefinitions[ftMemo] := 'TEXT'; FieldtypeDefinitions[ftMemo] := 'TEXT';
FieldtypeDefinitions[ftGraphic] := ''; FieldtypeDefinitions[ftGraphic] := '';
end; end;
@ -152,12 +152,14 @@ begin
if SQLDbType in [mysql40,mysql41,mysql50,mysql51,odbc,interbase] then if SQLDbType in [mysql40,mysql41,mysql50,mysql51,odbc,interbase] then
begin 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) // Firebird support miliseconds, see BUG 17199 (when resolved, then interbase can be excluded)
for t := 0 to testValuesCount-1 do for t := 0 to testValuesCount-1 do
begin begin
testTimeValues[t] := copy(testTimeValues[t],1,8)+'.000'; testTimeValues[t] := copy(testTimeValues[t],1,8)+'.000';
testValues[ftTime,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;
end; end;
if SQLDbType in [postgresql,interbase] then if SQLDbType in [postgresql,interbase] then

View File

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

View File

@ -220,6 +220,8 @@ begin
FFormatSettings.ThousandSeparator:=#0; FFormatSettings.ThousandSeparator:=#0;
FFormatSettings.DateSeparator:='-'; FFormatSettings.DateSeparator:='-';
FFormatSettings.TimeSeparator:=':'; FFormatSettings.TimeSeparator:=':';
FFormatSettings.ShortDateFormat:='yyyy/mm/dd';
FFormatSettings.LongTimeFormat:='hh:nn:ss.zzz';
FUsedDatasets := TFPList.Create; FUsedDatasets := TFPList.Create;
CreateFieldDataset; CreateFieldDataset;
CreateNDatasets; CreateNDatasets;
@ -315,9 +317,13 @@ begin
// The decimalseparator was set to a comma for currencies and to a dot for ftBCD values. // 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 // 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 // Here we assume, that locale on client side is same as locale on server
testValues[ftCurrency,i] := CurrToStr(testCurrencyValues[i]); testValues[ftCurrency,i] := CurrToStr(testCurrencyValues[i]);
testValues[ftBCD,i] := CurrToStr(testCurrencyValues[i],FormatSettings); 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; end;
if dbconnectorname = '' then raise Exception.Create('There is no db-connector specified'); if dbconnectorname = '' then raise Exception.Create('There is no db-connector specified');