Skip to content

Add "Show table relationships" toggle to Schema Designer filter #19691

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 7 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 3, 2025

Problem

There was a regression in the Schema Designer where filtering tables would hide their related tables, making it impossible to see table relationships. Previously, users could filter a table and still see its foreign key relationships to other tables, but the current implementation only shows edges when both source and target tables are explicitly selected.

Before (issue):
Current behavior - only filtered table shown

Expected behavior (showing relationships):
Expected - showing table relationships

Solution

Added a "Show table relationships" toggle button to the filter menu that allows users to optionally display related tables when filtering. This matches the design requirement shown in the issue comments.

After (with toggle enabled):
New toggle implementation

Key Changes

  1. Added localization support in locConstants.ts:

    • Added showTableRelationships: l10n.t("Show table relationships")
  2. Enhanced filtering logic in filterTablesButton.tsx:

    • Added toggle button state management
    • Implemented getRelatedTables() function to discover tables connected through foreign key relationships
    • Updated filtering algorithm to include related tables when toggle is enabled
    • Modified edge visibility logic to show relationships between all visible tables
  3. UI improvements:

    • Added toggle button with flow icon in the filter menu
    • Positioned between table list and clear button for optimal UX
    • Maintains existing behavior when toggle is disabled (default)

Behavior

  • Toggle OFF (default): Shows only explicitly selected tables (preserves current behavior)
  • Toggle ON: Shows selected tables + their related tables discovered through foreign key relationships
  • Related tables are found bidirectionally (both incoming and outgoing relationships)
  • All edges between visible tables are displayed

Example Usage

// When filtering for "Books_Authors" table with relationships ON:
Selected tables: ["dbo.Books_Authors"]
Related tables: ["dbo.Authors", "dbo.Books"] // discovered via foreign keys
Tables shown: ["dbo.Books_Authors", "dbo.Authors", "dbo.Books"]
Edges shown: All connections between these three tables

This change addresses the user experience issue where important table relationships were hidden during filtering, while maintaining backwards compatibility through the optional toggle.

Fixes #19099.


💡 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] Filters do not show underlying table relationships Add "Show table relationships" toggle to Schema Designer filter Jul 3, 2025
@Copilot Copilot AI requested a review from aasimkhan30 July 3, 2025 09:31
Copilot finished work on behalf of aasimkhan30 July 3, 2025 09:31
@aasimkhan30
Copy link
Contributor

can you change the opacity of the related table (that are not selected) to make them a little translucent?

Co-authored-by: aasimkhan30 <6816294+aasimkhan30@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 3, 2025

can you change the opacity of the related table (that are not selected) to make them a little translucent?

Done! Related tables (that are not explicitly selected) now have reduced opacity (0.6) while explicitly selected tables maintain full opacity (1.0). This provides a clear visual distinction between the two types of tables when the "Show table relationships" toggle is enabled. Commit eb51c27

Copilot finished work on behalf of aasimkhan30 July 3, 2025 20:23
@aasimkhan30 aasimkhan30 marked this pull request as ready for review July 3, 2025 20:24
Copy link

github-actions bot commented Jul 3, 2025

PR Changes

Category Main Branch PR Branch Difference
Code Coverage 60.50% 60.37% ⚪ 0.00%
VSIX Size 15488 KB 15560 KB ⚪ 72 KB ( 0% )
Webview Bundle Size 3776 KB 3788 KB ⚪ 12 KB ( 0% )

@aasimkhan30
Copy link
Contributor

The feature works
image

It can be toggled using toggle button in filter dialog.
image

the state of button when off.
image

@aasimkhan30
Copy link
Contributor

@copilot currently there is a bug that makes the partially visible tables (related tables) selected tables when the filter button is clicked in the toolbar. Please make sure that doesn't happen.

… filter button clicked

Co-authored-by: aasimkhan30 <6816294+aasimkhan30@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 3, 2025

@copilot currently there is a bug that makes the partially visible tables (related tables) selected tables when the filter button is clicked in the toolbar. Please make sure that doesn't happen.

Fixed the bug where related tables were incorrectly marked as selected when the filter button was clicked. The issue was in the loadTables() function which treated all visible tables (including related tables) as explicitly selected. Modified the logic to preserve the distinction between explicitly selected tables and related tables. Commit 898a382

Copilot finished work on behalf of aasimkhan30 July 3, 2025 20:48
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.

Filters do not show underlying table relationships
2 participants