Skip to content

Add missing foreign key icons in Schema Designer table nodes #19689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 3, 2025

This PR fixes the missing foreign key icons in the Schema Designer table view. Previously, only primary key columns were visually distinguished with icons, while foreign key columns had no visual indication of their relationship to other tables.

Problem

In the Schema Designer, foreign key columns like id_author were not showing any visual indicators, making it difficult to identify relationships between tables at a glance. The TableColumn component only checked for primary keys but ignored foreign key relationships.

Before - Missing Foreign Key Icons

As shown in the first image, the id_author column (which is a foreign key referencing the dbo.Authors table) appears without any icon, making the relationship invisible to users.

Solution

Added foreign key detection logic to the TableColumn component:

// Check if this column is a foreign key
const isForeignKey = table.foreignKeys.some((fk) => fk.columns.includes(column.name));

// Show foreign key icon for non-primary key columns
{!column.isPrimaryKey && isForeignKey && (
    <FluentIcons.FlowRegular className={styles.keyIcon} />
)}

Changes Made

  • Foreign Key Detection: Added logic to check if a column participates in any foreign key relationship
  • Icon Rendering: Used FlowRegular icon from FluentUI (consistent with relationship management UI)
  • Component Updates: Updated TableColumn and TableColumns components to pass table data for foreign key detection
  • Styling: Foreign key icons use the same styling as primary key icons for consistency
  • Icon Precedence: Primary key icons take precedence when a column is both a primary and foreign key

Edge Cases Handled

  • ✅ Columns that are both primary and foreign keys (primary key icon takes precedence)
  • ✅ Multi-column foreign keys (all participating columns show the icon)
  • ✅ Tables with no foreign keys (no change in behavior)
  • ✅ Empty foreign key arrays (gracefully handled)

Visual Impact

Foreign key columns now display a flow icon (🔗) to clearly indicate they reference another table, making database relationships immediately visible in the Schema Designer.

After - With Foreign Key Icons

The second image shows the foreign key configuration panel, confirming that id_author is indeed configured as a foreign key referencing dbo.Authors.AuthorID.

Fixes #19100.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: /usr/local/bin/node ./out/test/unit/runTest.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: aasimkhan30 <6816294+aasimkhan30@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Key icon is missing for foreign keys Add missing foreign key icons in Schema Designer table nodes Jul 3, 2025
@Copilot Copilot AI requested a review from aasimkhan30 July 3, 2025 08:54
Copilot finished work on behalf of aasimkhan30 July 3, 2025 08:54
@aasimkhan30
Copy link
Contributor

Verified the fix.
image

@aasimkhan30 aasimkhan30 marked this pull request as ready for review July 3, 2025 09:10
Copy link

github-actions bot commented Jul 3, 2025

PR Changes

Category Main Branch PR Branch Difference
Code Coverage 60.46% 60.37% ⚪ 0.00%
VSIX Size 15488 KB 15504 KB ⚪ 16 KB ( 0% )
Webview Bundle Size 3776 KB 3776 KB ⚪ 0 KB ( 0% )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key icon is missing for foreign keys
2 participants