Skip to content

Commit 6229c50

Browse files
committed
fix: quote schema-qualified identifiers segment-wise on drag+drop into query editor. See issue #2645
1 parent ef4c6da commit 6229c50

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎source/main.pas‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7777,6 +7777,7 @@ procedure TMainForm.SynMemoQueryDragDrop(Sender, Source: TObject; X,
77777777
QueryTabs.ActiveMemo.UndoList.AddGroupBreak;
77787778
src := Source as TControl;
77797779
Text := '';
7780+
// Adds database.[table.] prefix
77807781
ShiftPressed := KeyPressed(VK_SHIFT);
77817782
Tree := QueryTabs.ActiveHelpersTree;
77827783
// Check for allowed controls as source has already
@@ -7785,14 +7786,15 @@ procedure TMainForm.SynMemoQueryDragDrop(Sender, Source: TObject; X,
77857786
// Insert table or database name. If a table is dropped and Shift is pressed, prepend the db name.
77867787
case ActiveDbObj.NodeType of
77877788
lntDb: Text := ActiveDbObj.QuotedDatabase(False);
7788-
lntTable..lntEvent, lntColumn: begin
7789-
Text := '';
7790-
if ShiftPressed then begin
7791-
Text := Text + ActiveDbObj.QuotedDatabase(False) + '.';
7792-
if ActiveDbObj.NodeType = lntColumn then
7793-
Text := Text + ActiveDbObj.QuotedName(False) + '.';
7794-
end;
7795-
Text := Text + ActiveDbObj.Connection.QuoteIdent(DBtree.Text[DBtree.FocusedNode, DBtree.FocusedColumn], False);
7789+
lntTable..lntEvent: begin
7790+
if ShiftPressed then
7791+
Text := ActiveDbObj.QuotedDatabase(False) + '.';
7792+
Text := Text + ActiveDbObj.QuotedName(False);
7793+
end;
7794+
lntColumn: begin
7795+
if ShiftPressed then
7796+
Text := ActiveDbObj.QuotedDatabase(False) + '.' + ActiveDbObj.QuotedName(False) + '.';
7797+
Text := Text + ActiveDbObj.QuotedColumn(False);
77967798
end;
77977799
end;
77987800
end else if src = Tree then begin
@@ -10059,6 +10061,7 @@ procedure TMainForm.DBtreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node:
1005910061
Item.NodeType := lntColumn;
1006010062
Columns := ParentObj.TableColumns;
1006110063
Item.Database := ParentObj.Database;
10064+
Item.Schema := ParentObj.Schema;
1006210065
Item.Name := ParentObj.Name;
1006310066
Item.Column := Columns[Node.Index].Name;
1006410067
end;

0 commit comments

Comments
 (0)