Skip to content
Permalink
Browse files

Issue #762: add informational message when foreign key'd column has t…

…oo many rows in the connected table, and raise limit from 1000 to 10000.
  • Loading branch information...
ansgarbecker committed Oct 5, 2019
1 parent d191f1c commit 375af4b372313c85b3af5a7db253eba2cd989972
Showing with 10 additions and 3 deletions.
  1. +4 −1 out/locale/en/LC_MESSAGES/default.po
  2. +6 −2 source/main.pas
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2019-09-16 20:35+0200\n"
"PO-Revision-Date: 2019-10-05 14:07+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
@@ -2868,6 +2868,9 @@ msgstr "Remember filters, sorting and column selection across sessions"
msgid "Show values in foreign key columns"
msgstr "Show values in foreign key columns"

msgid "Connected table has too many rows. Foreign key drop-down is limited to %d items."
msgstr "Connected table has too many rows. Foreign key drop-down is limited to %d items."

#. optionsform..pagecontrolMain..tabShortcuts..Caption
#: options.dfm:843
msgid "Shortcuts"
@@ -9487,6 +9487,8 @@ procedure TMainForm.AnyGridEditCancelled(Sender: TBaseVirtualTree; Column:

procedure TMainForm.AnyGridCreateEditor(Sender: TBaseVirtualTree; Node:
PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink);
const
ForeignItemsLimit: Integer = 10000;
var
VT: TVirtualStringTree;
HexEditor: THexEditorLink;
@@ -9536,10 +9538,10 @@ procedure TMainForm.AnyGridCreateEditor(Sender: TBaseVirtualTree; Node:
if TextCol <> '' then SQL := SQL + ', LEFT(' + Conn.QuoteIdent(TextCol) + ', 256)';
SQL := SQL + ' FROM '+Conn.QuoteIdent(ForeignKey.ReferenceTable, True, '.')+' GROUP BY '+KeyCol+' ORDER BY ';
if TextCol <> '' then SQL := SQL + Conn.QuoteIdent(TextCol) else SQL := SQL + KeyCol;
SQL := SQL + ' LIMIT 1000';
SQL := SQL + ' LIMIT ' + ForeignItemsLimit.ToString;

ForeignResults := Conn.GetResults(SQL);
if ForeignResults.RecordCount < 1000 then begin
if ForeignResults.RecordCount < ForeignItemsLimit then begin
EnumEditor := TEnumEditorLink.Create(VT);
EditLink := EnumEditor;
while not ForeignResults.Eof do begin
@@ -9548,6 +9550,8 @@ procedure TMainForm.AnyGridCreateEditor(Sender: TBaseVirtualTree; Node:
EnumEditor.DisplayList.Add(ForeignResults.Col(0)+': '+ForeignResults.Col(1));
ForeignResults.Next;
end;
end else begin
LogSQL(f_('Connected table has too many rows. Foreign key drop-down is limited to %d items.', [ForeignItemsLimit]), lcInfo);
end;
ForeignResults.Free;
break;

0 comments on commit 375af4b

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