Support BIT data type in MS SQL. Fixes issue #2955.

This commit is contained in:
Ansgar Becker
2013-02-24 10:49:33 +00:00
parent d03ae628cc
commit 9841bc3f21
2 changed files with 18 additions and 2 deletions

View File

@ -4001,6 +4001,12 @@ begin
except except
Result := String(FCurrentResults.Fields[Column].AsAnsiString); Result := String(FCurrentResults.Fields[Column].AsAnsiString);
end; end;
if Datatype(Column).Index = dtBit then begin
if UpperCase(Result) = 'TRUE' then
Result := '1'
else
Result := '0';
end;
end; end;
end else if not IgnoreErrors then end else if not IgnoreErrors then
Raise EDatabaseError.CreateFmt(_(MsgInvalidColumn), [Column, ColumnCount, RecordCount]); Raise EDatabaseError.CreateFmt(_(MsgInvalidColumn), [Column, ColumnCount, RecordCount]);
@ -4445,7 +4451,7 @@ begin
else case Datatype(i).Category of else case Datatype(i).Category of
dtcInteger, dtcReal: begin dtcInteger, dtcReal: begin
Val := Cell.NewText; Val := Cell.NewText;
if Datatype(i).Index = dtBit then if (Datatype(i).Index = dtBit) and (FConnection.Parameters.NetTypeGroup=ngMySQL) then
Val := 'b' + Connection.EscapeString(Val); Val := 'b' + Connection.EscapeString(Val);
end; end;
dtcBinary, dtcSpatial: dtcBinary, dtcSpatial:

View File

@ -812,7 +812,7 @@ var
); );
MSSQLDatatypes: array [0..25] of TDBDatatype = MSSQLDatatypes: array [0..26] of TDBDatatype =
( (
( (
Index: dtTinyint; Index: dtTinyint;
@ -854,6 +854,16 @@ var
HasDefault: True; HasDefault: True;
Category: dtcInteger; Category: dtcInteger;
), ),
(
Index: dtBit;
Name: 'BIT';
Description: '0 or 1';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: True;
Category: dtcInteger;
),
( (
Index: dtDecimal; Index: dtDecimal;
Name: 'DECIMAL'; Name: 'DECIMAL';