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

Modify constraints API to list foreign key constraints #943

Closed
Tracked by #451
seancolsen opened this issue Jan 5, 2022 · 2 comments · Fixed by #1375
Closed
Tracked by #451

Modify constraints API to list foreign key constraints #943

seancolsen opened this issue Jan 5, 2022 · 2 comments · Fixed by #1375
Assignees
Labels
type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL

Comments

@seancolsen
Copy link
Contributor

seancolsen commented Jan 5, 2022

Current behavior

  • I can see unique and primary key constraints with a GET to /tables/{table_id}/constraints/, but the response does not include FK constraints.

Desired behavior

  • FK constraints should be included in the constraints response.
  • Additional FK-specific details about each FK constraint should be present too, including:
    • Target columns of the FK
    • ON DELETE behavior
    • ON UPDATE behavior
    • MATCH behavior
    • DEFERRED behavior

Considerations

  • A foreign key might be associated with more than one column, and in such cases will reference more than one column too. We're not planning to add support for creating multi-column FKs any time soon, but we do need support for displaying them, so the API needs to respond by showing all the constraint columns and all the target columns.
  • Note that API consumers also need a way to associate each constraint column with its corresponding target column. If we return the constraint columns separately from the target columns, that's fine as long as the ordering of those two arrays is suitable for associating the columns by array index.
  • The UI eventually want to display a specific warning in the front end when the user is deleting rows that will cascade in case of constraints with ON DELETE CASCADE.

Spec Prompts

The person implementing this issue should spec out their proposed API changes and run them by the Mathesar core team. Questions the spec should answer include:

  • How does the response indicate the target table and target columns?
  • How does the response provide info about the FK-specific details listed above?

Additional context

@seancolsen seancolsen added status: draft type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL labels Jan 5, 2022
@seancolsen seancolsen added this to the [08] Working with Views milestone Jan 5, 2022
@seancolsen
Copy link
Contributor Author

@kgodey I'm assigning this to you to help answer the above questions and loop others in as needed.

@kgodey
Copy link
Contributor

kgodey commented Jan 10, 2022

Updated description to handle open questions.

@kgodey kgodey modified the milestones: [09] Working with Views, [08] Links Between Tables Jan 18, 2022
@kgodey kgodey added ready Ready for implementation and removed needs: unblocking Blocked by other work labels Mar 4, 2022
@silentninja silentninja self-assigned this Mar 25, 2022
@silentninja silentninja added status: started and removed ready Ready for implementation labels Mar 25, 2022
Repository owner moved this from Started to Done in [NO LONGER USED] Mathesar work tracker May 12, 2022
@kgodey kgodey removed this from the [08] Links between Tables milestone Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request work: backend Related to Python, Django, and simple SQL
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants