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

Insert broken when there's not primary key #3246

Closed
mathemancer opened this issue Oct 17, 2023 · 2 comments · Fixed by #3252
Closed

Insert broken when there's not primary key #3246

mathemancer opened this issue Oct 17, 2023 · 2 comments · Fixed by #3252
Assignees
Labels
ready Ready for implementation type: bug Something isn't working work: backend Related to Python, Django, and simple SQL
Milestone

Comments

@mathemancer
Copy link
Contributor

Description

When a table does not have a primary key, attempting to use the UI to create a new record results in the backend throwing an unhandled 500 error.

Expected behavior

When a POST request representing a new empty record is sent for a table with no primary key, the server should respond with a 405 error, since we can't allow creating (or editing) rows on tables with no primary key. The error should be associated with some informational APIException stating that you can't insert into tables without a primary key.

The implementer should add an API test to validate their solution.

To Reproduce

  1. Using psql or some other client, create a table without a primary key.
  2. In the UI, navigate to that table.
  3. Click the + to add a record.
    image
  4. Observe the 500 response.
  5. See the error (via mouse-over) in the UI:
    image
  6. See the tuple index out of range error in the devtools.
@mathemancer mathemancer added type: bug Something isn't working status: triage labels Oct 17, 2023
@mathemancer mathemancer added work: backend Related to Python, Django, and simple SQL ready Ready for implementation and removed status: triage labels Oct 17, 2023
@mathemancer mathemancer added this to the Backlog milestone Oct 17, 2023
@piyushupadhyay19
Copy link

Hi Everyone, I'm taking up this issue and have started working on it. I'll keep you updated on my progress.

@piyushupadhyay19
Copy link

piyushupadhyay19 commented Oct 20, 2023

Hey, I observed that the Mathesar web interface displays 'mathesar_tables' as a database. However, I couldn't connect to mathesar_tables database. I successfully connected to 'mathesar_django' database and made a table there using psql but I cannot find that table in UI because I think table needs to be created in mathesar_tables database and not mathesar_django database? Can you please clarify if 'mathesar_tables' is an alias for another database specified in my project's configuration, or if there's a different method to access it?

However, I successfully reproduced the issue, by making table through UI and then deleting the id column from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Ready for implementation type: bug Something isn't working work: backend Related to Python, Django, and simple SQL
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants