[patch_done] Trouble Metadata + Firebird
Posted: 06.10.2008, 17:54
Hi everybody:
on \src\dbc\ZDbcMetadata.pas
function TZAbstractDatabaseMetadata.CloneCachedResultSet(
ResultSet: IZResultSet): IZResultSet;
var
I: Integer;
Metadata: IZResultSetMetadata;
ColumnInfo: TZColumnInfo;
ColumnsInfo: TObjectList;
begin
Result := nil;
Metadata := ResultSet.GetMetadata;
ColumnsInfo := TObjectList.Create;
try
for I := 1 to Metadata.GetColumnCount do
begin
ColumnInfo := TZColumnInfo.Create;
with ColumnInfo do
begin
ColumnLabel := Metadata.GetColumnLabel(I);
ColumnType := Metadata.GetColumnType(I);
ColumnDisplaySize := Metadata.GetPrecision(I);
Precision := Metadata.GetPrecision(I);
end;
ColumnsInfo.Add(ColumnInfo);
end;
ResultSet.BeforeFirst;
Result := CopyToVirtualResultSet(ResultSet,
TZVirtualResultSet.CreateWithColumns(ColumnsInfo, ''));
ResultSet.BeforeFirst;
finally
// ColumnsInfo.Free;
end;
end;
I don't understand why ResultSet.BeforeFirst; is commented, because uncommenting it several test are passed correctly , so I suggest you uncomment it.
Second this test contain several mistakes .. please change it to this solution:
\test\component\ZTestStoredProcedure.pas
procedure TZTestInterbaseStoredProcedure.TestStoredProc;
begin
StoredProc.StoredProcName := 'PROCEDURE1';
try
CheckEquals(2, StoredProc.Params.Count);
CheckEquals('R1', StoredProc.Params[0].Name);
CheckEquals(ord(ptResult), ord(StoredProc.Params[0].ParamType));
CheckEquals('P1', StoredProc.Params[1].Name);
CheckEquals(ord(ptInput), ord(StoredProc.Params[1].ParamType));
StoredProc.Params[1].AsInteger := 12345;
StoredProc.ExecProc;
except
on e: exception do ShowMessage(e.Message);
end;
CheckEquals(12346, StoredProc.Params[0].AsInteger);
CheckEquals(2, StoredProc.Params.Count);
end;
Best regards
on \src\dbc\ZDbcMetadata.pas
function TZAbstractDatabaseMetadata.CloneCachedResultSet(
ResultSet: IZResultSet): IZResultSet;
var
I: Integer;
Metadata: IZResultSetMetadata;
ColumnInfo: TZColumnInfo;
ColumnsInfo: TObjectList;
begin
Result := nil;
Metadata := ResultSet.GetMetadata;
ColumnsInfo := TObjectList.Create;
try
for I := 1 to Metadata.GetColumnCount do
begin
ColumnInfo := TZColumnInfo.Create;
with ColumnInfo do
begin
ColumnLabel := Metadata.GetColumnLabel(I);
ColumnType := Metadata.GetColumnType(I);
ColumnDisplaySize := Metadata.GetPrecision(I);
Precision := Metadata.GetPrecision(I);
end;
ColumnsInfo.Add(ColumnInfo);
end;
ResultSet.BeforeFirst;
Result := CopyToVirtualResultSet(ResultSet,
TZVirtualResultSet.CreateWithColumns(ColumnsInfo, ''));
ResultSet.BeforeFirst;
finally
// ColumnsInfo.Free;
end;
end;
I don't understand why ResultSet.BeforeFirst; is commented, because uncommenting it several test are passed correctly , so I suggest you uncomment it.
Second this test contain several mistakes .. please change it to this solution:
\test\component\ZTestStoredProcedure.pas
procedure TZTestInterbaseStoredProcedure.TestStoredProc;
begin
StoredProc.StoredProcName := 'PROCEDURE1';
try
CheckEquals(2, StoredProc.Params.Count);
CheckEquals('R1', StoredProc.Params[0].Name);
CheckEquals(ord(ptResult), ord(StoredProc.Params[0].ParamType));
CheckEquals('P1', StoredProc.Params[1].Name);
CheckEquals(ord(ptInput), ord(StoredProc.Params[1].ParamType));
StoredProc.Params[1].AsInteger := 12345;
StoredProc.ExecProc;
except
on e: exception do ShowMessage(e.Message);
end;
CheckEquals(12346, StoredProc.Params[0].AsInteger);
CheckEquals(2, StoredProc.Params.Count);
end;
Best regards