Skip to content
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

Fix: Display correct record summary for linked cells after adding for… #4267

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

cwyoan
Copy link

@cwyoan cwyoan commented Feb 18, 2025

…eign key constraint (Fixes #4237)

Fixes #[4237]

I added some code that checks for when the FK constraints are finished updating so that not only do the constraints refresh but so do the records data. This ensures that the record summary data is being displayed instead of their IDs.

before:

Screenshot 2025-02-17 at 7 57 52 PM

after:
Screenshot 2025-02-17 at 6 47 24 PM

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@zackkrida zackkrida requested a review from seancolsen February 18, 2025 19:43
@zackkrida zackkrida added the pr-status: review A PR awaiting review label Feb 18, 2025
Copy link
Contributor

@seancolsen seancolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cwyoan Thanks for your eagerness to help out. There are a problems here though...

  1. Generally, it's not a great idea to call subscribe on a Svelte store because these subscriptions don't get cleaned up automatically which can lead to memory leaks. This is something the Svelte team has addressed in Svelte 5 because signals have a scope that is automatically tracked and the $effect rune doesn't need any cleanup. But it will be a while until we can use Svelte 5 within Mathesar. While it's possible to manually handle the unsubscription, I'd like to point you to another patter to follow in this case. Slightly above your chances you can see how we're handling the case of a new column being added:

    this.columnsDataStore.on('columnAdded', async () => {
      await this.recordsData.fetch();
    });

    This is possible because ColumnsDataStore inherits EventHandler which offers the on method.

    I'd like you to set up ConstraintsDataStore in the same manner.

    I'll admit this is some additional complexity which I didn't foresee when writing up the comments in the issue. Sorry about that.

  2. The name FKconst doesn't follow our naming conventions, though I imagine you won't have this variable anymore after following the new pattern I've described above.

  3. Make sure to run prettier.

@seancolsen seancolsen assigned cwyoan and unassigned seancolsen Feb 20, 2025
@seancolsen seancolsen added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: revision A PR awaiting follow-up work from its author after review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After adding a foreign key constraint the record summary for linked cells doesn't display correctly
4 participants