Internally, always use binary strings, not hex strings, when inserting or updating grid rows. Fixes SQL errors when actBlobAsText is activated and UPDATE sends unquoted "_binary foobar" as value. Fixes issue #2166. Also, do not reload grid data when activating text display.

This commit is contained in:
Ansgar Becker
2010-09-19 23:04:56 +00:00
parent 243a553d9d
commit 18f67ffdc3
3 changed files with 7 additions and 3 deletions

View File

@ -50,8 +50,13 @@ uses helpers, main;
function TfrmBinEditor.GetText: String;
var
Ansi: AnsiString;
begin
Result := '0x' + memoText.Text;
// Convert hex to binary string before returning
SetLength(Ansi, memoText.GetTextLen div 2);
HexToBin(PWideChar(memoText.Text), PAnsiChar(Ansi), Length(Ansi));
Result := String(Ansi);
end;
procedure TfrmBinEditor.SetText(text: String);

View File

@ -9173,7 +9173,7 @@ end;
procedure TMainForm.actBlobAsTextExecute(Sender: TObject);
begin
// Activate displaying BLOBs as text data, ignoring possible weird effects in grid updates/inserts
InvalidateVT(DataGrid, VTREE_NOTLOADED_PURGECACHE, False);
DataGrid.InvalidateChildren(nil, True);
end;

View File

@ -2140,7 +2140,6 @@ begin
Val := 'NULL'
else case Datatype(i).Category of
dtcInteger, dtcReal: Val := Cell.NewText;
dtcBinary: Val := '_binary ' + Cell.NewText;
else Val := Connection.EscapeString(Cell.NewText);
end;
sqlUpdate := sqlUpdate + Connection.QuoteIdent(FColumnOrgNames[i]) + '=' + Val;