Como bien comenta
rhino0nt en la bdd se define como TINYINT(1).
Después en el Delphi, usamos Zeos, y en la unit
ZAbstractRODataset tengo una pequeña modificación en la siguiente función:
Código:
procedure TZAbstractRODataset.InternalInitFieldDefs;
var
I, J, Size: Integer;
AutoInit: Boolean;
FieldType: TFieldType;
ResultSet: IZResultSet;
FieldName: string;
FName: string;
begin
FieldDefs.Clear;
ResultSet := Self.ResultSet;
AutoInit := ResultSet = nil;
try
{ Opens an internal result set if query is closed. }
if AutoInit then
begin
CheckSQLQuery;
CheckConnected;
ResultSet := CreateResultSet(FSQL.Statements[0].SQL, 0);
end;
if not Assigned(ResultSet) then
raise Exception.Create(SCanNotOpenResultSet);
{ Reads metadata from resultset. }
with ResultSet.GetMetadata do
begin
if GetColumnCount > 0 then for I := 1 to GetColumnCount do
begin
FieldType := ConvertDbcToDatasetType(GetColumnType(I));
if FieldType in [ftString, ftWidestring, ftBytes] then
Size := GetPrecision(I)
else Size := 0;
//TinyInt(1)= SmallInt = Boolean
if ( (FieldType=ftSmallInt)
or (FieldType=ftInteger)
or (FieldType=ftLargeint)
)
and (GetPrecision(I)=1)
then FieldType:=ftBoolean;
//TinyInt(1)= SmallInt = Boolean
J := 0;
FieldName := GetColumnLabel(I);
FName := FieldName;
while FieldDefs.IndexOf(FName) >= 0 do
begin
Inc(J);
FName := Format('%s_%d', [FieldName, J]);
end;
with TFieldDef.Create(FieldDefs, FName, FieldType,
Size, False, I) do
begin
{$IFNDEF FPC}
{$IFNDEF FOSNOMETA}
Required := IsWritable(I) and (IsNullable(I) = ntNoNulls);
{$ENDIF}
{$ENDIF}
{$IFNDEF FOSNOMETA}
if IsReadOnly(I) then Attributes := Attributes + [faReadonly];
Precision := GetPrecision(I);
{$ENDIF}
DisplayName := FName;
end;
end;
end;
finally
{ Closes localy opened resultset. }
if AutoInit then
begin
if ResultSet <> nil then
begin
ResultSet.Close;
ResultSet := nil;
end;
if Statement <> nil then
begin
Statement.Close;
Statement := nil;
end;
end;
end;
end;
Recompilamos las Zeos, y ya podemos usar los Tinyint(1) como si fueran ftBoolean, incluso en diseño.
Saludos!!