mathesar-foundation / mathesar

Web application providing an intuitive user experience to databases.
https://mathesar.org/
GNU General Public License v3.0
2.36k stars 327 forks source link

Implement tables.list and tables.delete RPC APIs on the schema page #3651

Closed seancolsen closed 2 months ago

seancolsen commented 3 months ago

This PR implements the following RPC methods on the schema page, making it possible to list tables, delete tables, and patch tables.

Endpoint HTTP Method Function
/api/db/v0/tables/ GET tables.list
/api/db/v0/tables/{tableId}/ DELETE tables.delete
/api/db/v0/tables/{tableId}/ PATCH tables.patch

I'll handle creating tables in a separate PR.

Checklist

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. ```
seancolsen commented 2 months ago

Sorry — this is not ready for review yet. I just discovered a really annoying bug that's going to be tricky to troubleshoot.

seancolsen commented 2 months ago

Ok I'm throwing up my hands a bit at this error I was seeing.

When loading the schema page via client-side navigation from the database page, I was observing an uncaught Tables store not found error, which is thrown here. I was able to reproduce this consistently during my initial inspection. And I was consistently not reproducing it when loading the schema page from the server. Then I made some changes to my user data, deleting a few tables, to make it easier to troubleshoot. That seems to have had the effect of making it impossible for me to reproduce this error. I've created more tables again to see if I can observe it. But it's quit elusive. I suspect this is some sort of race condition cropping up due to the messy way in which we're using stores. That mess would ideally be cleaned up, but I'd like to avoid that sort of refactor at this point.

I'm going to cross my fingers and hope this doesn't come back.

But @pavish if you see a Tables store not found error, please pay very careful attention to it and see if you can isolate the reproduction scenario.

seancolsen commented 2 months ago

@pavish as far as I can tell, this is a backend bug. I've opened #3702 to fix it.

Can you re-test with a schema that contains tables?

I've tested with a schema that has tables, both with and without metadata, and it seems to work.