mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 07:28:26 +02:00
* fix for using ftString-type parameters on datefields + test
git-svn-id: trunk@8553 -
This commit is contained in:
parent
d5fa108796
commit
5ae57ea554
@ -737,13 +737,20 @@ begin
|
||||
begin
|
||||
if assigned(in_sqlda^.SQLvar[SQLVarNr].SQLInd) then in_sqlda^.SQLvar[SQLVarNr].SQLInd^ := 0;
|
||||
|
||||
case AParams[ParNr].DataType of
|
||||
ftInteger :
|
||||
case (in_sqlda^.SQLvar[SQLVarNr].sqltype and not 1) of
|
||||
SQL_LONG :
|
||||
begin
|
||||
i := AParams[ParNr].AsInteger;
|
||||
Move(i, in_sqlda^.SQLvar[SQLVarNr].SQLData^, in_SQLDA^.SQLVar[SQLVarNr].SQLLen);
|
||||
end;
|
||||
ftString,ftFixedChar : if ((in_sqlda^.SQLvar[SQLVarNr].SQLType and not 1) = SQL_BLOB) then SetBlobParam else
|
||||
SQL_SHORT :
|
||||
begin
|
||||
i := AParams[ParNr].AsSmallInt;
|
||||
Move(i, in_sqlda^.SQLvar[SQLVarNr].SQLData^, in_SQLDA^.SQLVar[SQLVarNr].SQLLen);
|
||||
end;
|
||||
SQL_BLOB :
|
||||
SetBlobParam;
|
||||
SQL_VARYING, SQL_TEXT :
|
||||
begin
|
||||
s := AParams[ParNr].AsString;
|
||||
w := length(s); // a word is enough, since the max-length of a string in interbase is 32k
|
||||
@ -757,22 +764,17 @@ begin
|
||||
end
|
||||
else
|
||||
CurrBuff := in_sqlda^.SQLvar[SQLVarNr].SQLData;
|
||||
|
||||
Move(s[1], CurrBuff^, w);
|
||||
end;
|
||||
ftDate, ftTime, ftDateTime:
|
||||
SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TIMESTAMP :
|
||||
SetDateTime(in_sqlda^.SQLvar[SQLVarNr].SQLData, AParams[ParNr].AsDateTime, in_SQLDA^.SQLVar[SQLVarNr].SQLType);
|
||||
ftLargeInt:
|
||||
SQL_INT64:
|
||||
begin
|
||||
li := AParams[ParNr].AsLargeInt;
|
||||
Move(li, in_sqlda^.SQLvar[SQLVarNr].SQLData^, in_SQLDA^.SQLVar[SQLVarNr].SQLLen);
|
||||
end;
|
||||
ftFloat:
|
||||
SQL_DOUBLE, SQL_FLOAT:
|
||||
SetFloat(in_sqlda^.SQLvar[SQLVarNr].SQLData, AParams[ParNr].AsFloat, in_SQLDA^.SQLVar[SQLVarNr].SQLLen);
|
||||
ftBlob, ftMemo:
|
||||
begin
|
||||
SetBlobParam;
|
||||
end;
|
||||
else
|
||||
DatabaseErrorFmt(SUnsupportedParameter,[Fieldtypenames[AParams[ParNr].DataType]],self);
|
||||
end {case}
|
||||
|
@ -20,12 +20,13 @@ type
|
||||
private
|
||||
procedure CreateTableWithFieldType(ADatatype : TFieldType; ASQLTypeDecl : string);
|
||||
procedure TestFieldDeclaration(ADatatype: TFieldType; ADataSize: integer);
|
||||
procedure TestXXParamQuery(ADatatype : TFieldType; ASQLTypeDecl : string; testValuescount : integer);
|
||||
procedure TestXXParamQuery(ADatatype : TFieldType; ASQLTypeDecl : string; testValuescount : integer; Cross : boolean = false);
|
||||
protected
|
||||
procedure SetUp; override;
|
||||
procedure TearDown; override;
|
||||
procedure RunTest; override;
|
||||
published
|
||||
procedure TestCrossStringDateParam;
|
||||
procedure TestGetFieldNames;
|
||||
procedure TestUpdateIndexDefs;
|
||||
procedure TestSetBlobAsMemoParam;
|
||||
@ -729,7 +730,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TTestFieldTypes.TestXXParamQuery(ADatatype : TFieldType; ASQLTypeDecl : string; testValuescount : integer);
|
||||
procedure TTestFieldTypes.TestXXParamQuery(ADatatype : TFieldType; ASQLTypeDecl : string; testValuescount : integer; Cross : boolean = false);
|
||||
|
||||
var i : integer;
|
||||
|
||||
@ -753,13 +754,16 @@ begin
|
||||
ftInteger: Params.ParamByName('field1').asinteger := testIntValues[i];
|
||||
ftFloat : Params.ParamByName('field1').AsFloat := testFloatValues[i];
|
||||
ftString : Params.ParamByName('field1').AsString := testStringValues[i];
|
||||
ftDate : Params.ParamByName('field1').AsDateTime:= StrToDate(testDateValues[i]);
|
||||
ftDate : if cross then
|
||||
Params.ParamByName('field1').AsString:= testDateValues[i]
|
||||
else
|
||||
Params.ParamByName('field1').AsDateTime:= StrToDate(testDateValues[i]);
|
||||
else
|
||||
AssertTrue('no test for paramtype available',False);
|
||||
end;
|
||||
ExecSQL;
|
||||
end;
|
||||
TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
||||
TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
||||
|
||||
sql.clear;
|
||||
sql.append('select * from FPDEV2 order by ID');
|
||||
@ -864,6 +868,11 @@ begin
|
||||
inherited RunTest;
|
||||
end;
|
||||
|
||||
procedure TTestFieldTypes.TestCrossStringDateParam;
|
||||
begin
|
||||
TestXXParamQuery(ftDate,'DATE',testDateValuesCount,True);
|
||||
end;
|
||||
|
||||
procedure TTestFieldTypes.TestGetFieldNames;
|
||||
var FieldNames : TStringList;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user