@@ -5148,11 +5148,13 @@ function TDBConnection.EscapeString(Text: String; ProcessJokerChars: Boolean=fal
51485148function TDBConnection.EscapeString (Text: String; Datatype: TDBDatatype): String;
51495149var
51505150 DoQuote: Boolean;
5151+ ValuePrefix: String;
51515152const
51525153 CategoriesNeedQuote = [dtcText, dtcBinary, dtcTemporal, dtcSpatial, dtcOther];
51535154begin
51545155 // Quote text based on the passed datatype
51555156 DoQuote := Datatype.Category in CategoriesNeedQuote;
5157+ ValuePrefix := ' ' ;
51565158 case Datatype.Category of
51575159 // Some special cases
51585160 dtcBinary: begin
@@ -5162,11 +5164,13 @@ function TDBConnection.EscapeString(Text: String; Datatype: TDBDatatype): String
51625164 dtcInteger, dtcReal: begin
51635165 if (not IsNumeric(Text)) and (not IsHex(Text)) then
51645166 DoQuote := True;
5165- if Datatype.Index = dbdtBit then
5167+ if ( Datatype.Index = dbdtBit) and FParameters.IsAnyMySQL then begin
51665168 DoQuote := True;
5169+ ValuePrefix := ' b' ;
5170+ end ;
51675171 end ;
51685172 end ;
5169- Result := EscapeString(Text, False, DoQuote);
5173+ Result := ValuePrefix + EscapeString(Text, False, DoQuote);
51705174end ;
51715175
51725176
@@ -9154,13 +9158,13 @@ function TSqlSrvQuery.Col(Column: Integer; IgnoreErrors: Boolean=False): String;
91549158 except
91559159 Result := String(FCurrentResults.Fields[Column].AsAnsiString);
91569160 end ;
9157- if Datatype(Column).Index = dbdtBit then begin
9158- if UpperCase(Result) = ' TRUE' then
9159- Result := ' 1'
9160- else
9161- Result := ' 0' ;
9162- end
91639161 end ;
9162+ if Datatype(Column).Index = dbdtBit then begin
9163+ if (UpperCase(Result) = ' TRUE' ) or (Result = ' 1' ) then
9164+ Result := ' 1'
9165+ else
9166+ Result := ' 0' ;
9167+ end
91649168 end else if not IgnoreErrors then
91659169 Raise EDbError.CreateFmt(_(MsgInvalidColumn), [Column, ColumnCount, RecordCount]);
91669170end ;
@@ -9862,11 +9866,8 @@ function TDBQuery.SaveModifications: Boolean;
98629866 else if Cell.NewIsFunction then
98639867 Val := Cell.NewText
98649868 else case Datatype(i).Category of
9865- dtcInteger, dtcReal: begin
9869+ dtcInteger, dtcReal:
98669870 Val := Connection.EscapeString(Cell.NewText, Datatype(i));
9867- if (Datatype(i).Index = dbdtBit) and FConnection.Parameters.IsAnyMySQL then
9868- Val := ' b' + Val;
9869- end ;
98709871 dtcBinary, dtcSpatial:
98719872 Val := FConnection.EscapeBin(Cell.NewText);
98729873 dtcTemporal:
@@ -10251,7 +10252,7 @@ function TDBQuery.GetWhereClause: String;
1025110252 case DataType(j).Category of
1025210253 dtcInteger, dtcReal: begin
1025310254 if DataType(j).Index = dbdtBit then
10254- Result := Result + ' =b ' + Connection.EscapeString(ColVal)
10255+ Result := Result + ' =' + Connection.EscapeString(ColVal, DataType(j) )
1025510256 else begin
1025610257 // Guess (!) the default value silently inserted by the server. This is likely
1025710258 // to be incomplete in cases where a UNIQUE key allows NULL here
0 commit comments