Skip to content
Permalink
Browse files

Fix no longer applied LEFT() on large text columns in data grid, for …

…data types with a max length over 2147483647
  • Loading branch information
ansgarbecker committed Feb 15, 2020
1 parent ee2a1e7 commit a7f17b748ed843a7d948147b6e25f8c64c908d6d
Showing with 4 additions and 4 deletions.
  1. +4 −4 source/main.pas
@@ -5141,8 +5141,8 @@ procedure TMainForm.DataGridBeforePaint(Sender: TBaseVirtualTree; TargetCanvas:
vt: TVirtualStringTree;
Select: String;
RefreshingData, IsKeyColumn: Boolean;
i, ColLen, ColWidth, VisibleColumns, MaximumRows, FullColumnCount: Integer;
Offset: Int64;
i, ColWidth, VisibleColumns, MaximumRows, FullColumnCount: Integer;
ColMaxLen, Offset: Int64;
KeyCols, ColWidths, WantedColumnOrgnames: TStringList;
WantedColumns: TTableColumnList;
c: TTableColumn;
@@ -5233,7 +5233,7 @@ procedure TMainForm.DataGridBeforePaint(Sender: TBaseVirtualTree; TargetCanvas:
for i:=0 to SelectedTableColumns.Count-1 do begin
c := SelectedTableColumns[i];
IsKeyColumn := KeyCols.IndexOf(c.Name) > -1;
ColLen := StrToInt64Def(c.LengthSet, 0);
ColMaxLen := StrToInt64Def(c.LengthSet, 0);
if (DatagridHiddenColumns.IndexOf(c.Name) = -1)
or (IsKeyColumn)
or (KeyCols.Count = 0)
@@ -5242,7 +5242,7 @@ procedure TMainForm.DataGridBeforePaint(Sender: TBaseVirtualTree; TargetCanvas:
and (KeyCols.Count > 0) // We need a sufficient key to be able to load remaining row data
and (c.DataType.LoadPart)
and (not IsKeyColumn) // We need full length of any key column, so DataGridLoadFullRow() has the chance to fetch the right row
and ((ColLen > GRIDMAXDATA) or (ColLen = 0)) // No need to blow SQL with LEFT() if column is shorter anyway
and ((ColMaxLen > GRIDMAXDATA) or (ColMaxLen = 0)) // No need to blow SQL with LEFT() if column is shorter anyway
then begin
case DBObj.Connection.Parameters.NetTypeGroup of
ngMSSQL: Select := Select + ' LEFT(CAST(' + DBObj.Connection.QuoteIdent(c.Name) + ' AS NVARCHAR('+IntToStr(GRIDMAXDATA)+')), ' + IntToStr(GRIDMAXDATA) + '), ';

0 comments on commit a7f17b7

Please sign in to comment.
You can’t perform that action at this time.