mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 13:49:39 +02:00
* Patch from Luiz Americo to implement SQL_NULL params on firebird (bug ID 37646)
git-svn-id: trunk@46756 -
This commit is contained in:
parent
c7628c11c6
commit
24ea912ff5
@ -164,6 +164,7 @@ uses
|
|||||||
const
|
const
|
||||||
SQL_BOOLEAN_INTERBASE = 590;
|
SQL_BOOLEAN_INTERBASE = 590;
|
||||||
SQL_BOOLEAN_FIREBIRD = 32764;
|
SQL_BOOLEAN_FIREBIRD = 32764;
|
||||||
|
SQL_NULL = 32767;
|
||||||
INVALID_DATA = -1;
|
INVALID_DATA = -1;
|
||||||
|
|
||||||
procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
|
procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
|
||||||
@ -834,7 +835,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
if ((SQLType and not 1) = SQL_VARYING) then
|
if ((SQLType and not 1) = SQL_VARYING) then
|
||||||
SQLData := AllocMem(in_SQLDA^.SQLVar[x].SQLLen+2)
|
SQLData := AllocMem(in_SQLDA^.SQLVar[x].SQLLen+2)
|
||||||
else
|
else if SQLType <> SQL_NULL then
|
||||||
SQLData := AllocMem(in_SQLDA^.SQLVar[x].SQLLen);
|
SQLData := AllocMem(in_SQLDA^.SQLVar[x].SQLLen);
|
||||||
// Always force the creation of slqind for parameters. It could be
|
// Always force the creation of slqind for parameters. It could be
|
||||||
// that a database trigger takes care of inserting null values, so
|
// that a database trigger takes care of inserting null values, so
|
||||||
@ -1211,7 +1212,8 @@ begin
|
|||||||
SQL_BOOLEAN_FIREBIRD:
|
SQL_BOOLEAN_FIREBIRD:
|
||||||
PByte(VSQLVar^.SQLData)^ := Byte(AParam.AsBoolean);
|
PByte(VSQLVar^.SQLData)^ := Byte(AParam.AsBoolean);
|
||||||
else
|
else
|
||||||
DatabaseErrorFmt(SUnsupportedParameter,[FieldTypeNames[AParam.DataType]],self);
|
if (VSQLVar^.sqltype <> SQL_NULL) then
|
||||||
|
DatabaseErrorFmt(SUnsupportedParameter,[FieldTypeNames[AParam.DataType]],self);
|
||||||
end {case}
|
end {case}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -62,6 +62,7 @@ type
|
|||||||
procedure TestMacros;
|
procedure TestMacros;
|
||||||
Procedure TestPrepareCount;
|
Procedure TestPrepareCount;
|
||||||
Procedure TestPrepareCount2;
|
Procedure TestPrepareCount2;
|
||||||
|
Procedure TestNullTypeParam;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTestTSQLConnection }
|
{ TTestTSQLConnection }
|
||||||
@ -839,6 +840,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestTSQLQuery.TestNullTypeParam;
|
||||||
|
begin
|
||||||
|
if not (SQLServerType in [ssSQLite, ssFirebird]) then
|
||||||
|
Ignore(STestNotApplicable);
|
||||||
|
CreateAndFillIDField;
|
||||||
|
try
|
||||||
|
With SQLDBConnector.Query do
|
||||||
|
begin
|
||||||
|
UsePrimaryKeyAsKey:=False; // Disable server index defs etc
|
||||||
|
SQL.Text:='Select ID from FPDEV2 where (:ID IS NULL or ID = :ID)';
|
||||||
|
Open;
|
||||||
|
AssertEquals('Correct record count param NULL',10,RecordCount);
|
||||||
|
Close;
|
||||||
|
ParamByname('ID').AsInteger:=1;
|
||||||
|
Open;
|
||||||
|
AssertEquals('Correct record count param 1',1,RecordCount);
|
||||||
|
AssertEquals('Correct field value: ',1,Fields[0].AsInteger);
|
||||||
|
Close;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
SQLDBConnector.Connection.OnLog:=Nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TTestTSQLConnection }
|
{ TTestTSQLConnection }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user