From 9841bc3f21a02d0fa60b6ac50b3d168fac931cb5 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 24 Feb 2013 10:49:33 +0000 Subject: [PATCH] Support BIT data type in MS SQL. Fixes issue #2955. --- source/dbconnection.pas | 8 +++++++- source/mysql_structures.pas | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 26a28cbc..b513432e 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -4001,6 +4001,12 @@ begin except Result := String(FCurrentResults.Fields[Column].AsAnsiString); end; + if Datatype(Column).Index = dtBit then begin + if UpperCase(Result) = 'TRUE' then + Result := '1' + else + Result := '0'; + end; end; end else if not IgnoreErrors then Raise EDatabaseError.CreateFmt(_(MsgInvalidColumn), [Column, ColumnCount, RecordCount]); @@ -4445,7 +4451,7 @@ begin else case Datatype(i).Category of dtcInteger, dtcReal: begin 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); end; dtcBinary, dtcSpatial: diff --git a/source/mysql_structures.pas b/source/mysql_structures.pas index 70d1e084..abefb0d9 100644 --- a/source/mysql_structures.pas +++ b/source/mysql_structures.pas @@ -812,7 +812,7 @@ var ); - MSSQLDatatypes: array [0..25] of TDBDatatype = + MSSQLDatatypes: array [0..26] of TDBDatatype = ( ( Index: dtTinyint; @@ -854,6 +854,16 @@ var HasDefault: True; Category: dtcInteger; ), + ( + Index: dtBit; + Name: 'BIT'; + Description: '0 or 1'; + HasLength: False; + RequiresLength: False; + HasBinary: False; + HasDefault: True; + Category: dtcInteger; + ), ( Index: dtDecimal; Name: 'DECIMAL';