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

Connections API #3309

Merged
merged 16 commits into from
Nov 24, 2023
Merged

Connections API #3309

merged 16 commits into from
Nov 24, 2023

Conversation

mathemancer
Copy link
Contributor

@mathemancer mathemancer commented Nov 15, 2023

Fixes #3291

This PR is an initial iteration towards replacing the "Database" concept in our codebase with a "DB Connection" (usually just "Connection") concept.

Technical details

The following endpoints are changed:

  • /api/ui/v0/databases/* -> /api/ui/v0/connections/*
  • /api/db/v0/databases/* -> /api/db/v0/connections/*

Note that as indicated by the wildcard, all endpoints under these namespaces are affected.

Changes to keys in JSON representations of connections (orig databases):

  • name -> nickname
  • db_name -> database
  • deleted -> (removed)
  • editable -> (removed)
  • error -> (removed)

Changes to common data JSON keys:

  • .current_db -> .current_db_connection
  • .databases -> .connections
  • .databases.[i].name -> .connections[0].nickname`
  • .databases.[i].db_name -> .connections[0].database`
  • .internal_database -> .internal_db_connection
  • .internal_database.db_name -> .internal_db_connection.database

Note that in order to keep this PR small, the Schema model refers to its database rather than connection in the API and common data.

Behavior changes:

When creating or updating a connection (formerly database) via POST or PATCH, we no longer test the actual connection or install Mathesar on the DB. That will be handled by a subsequent PR on the RPC endpoint.

Regarding MATHESAR_DATABASES:

I left that variable for now, since removing it would require rewriting major pieces of our back end test suite. However, I don't think it will affect much. I think we should remove that variable from our docs and examples, except for the dev setup, where having a preinstalled DB automatically created is convenient.

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.

@mathemancer mathemancer marked this pull request as draft November 15, 2023 14:57
@mathemancer
Copy link
Contributor Author

@Anish9901 Please review, but don't merge until @seancolsen makes the required front end changes.

@seancolsen seancolsen self-assigned this Nov 15, 2023
Copy link
Member

@Anish9901 Anish9901 left a comment

Choose a reason for hiding this comment

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

Looks great @mathemancer! I've addressed a small bug please take a look.

@@ -23,33 +23,10 @@ def get_supported_types_url(self, obj):
if isinstance(obj, Database) and not self.partial:
# Only get records if we are serializing an existing table
request = self.context['request']
return request.build_absolute_uri(reverse('database-types', kwargs={'pk': obj.pk}))
return request.build_absolute_uri(reverse('connection-types', kwargs={'pk': obj.pk}))
Copy link
Member

Choose a reason for hiding this comment

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

There is a minor bug here, the uri formed will always be namespaced under ui/ as the basename is same for both the db & ui route. Not sure how significant it is for the frontend though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm. I'll experiment with it a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Anish9901 I poked around and found that the behavior's the same as before. I agree that this is a bit of a bug, but it's apparently harmless. Given that we're going to be completely overhauling the API structure in the near future, I want to avoid fixing it for now.

@pavish pavish assigned pavish and unassigned seancolsen Nov 17, 2023
@pavish
Copy link
Member

pavish commented Nov 17, 2023

I'm taking over the frontend work from @seancolsen for changes needed in this PR.

@pavish
Copy link
Member

pavish commented Nov 23, 2023

@mathemancer @Anish9901 I've fixed the breaking changes on the frontend, except the previous 'Database Connections' settings page which will be rewritten as per the new spec. This PR can be merged when ready.

@pavish pavish assigned mathemancer and Anish9901 and unassigned pavish Nov 23, 2023
@mathemancer mathemancer marked this pull request as ready for review November 24, 2023 09:11
@mathemancer mathemancer removed the request for review from seancolsen November 24, 2023 09:11
@mathemancer mathemancer added this pull request to the merge queue Nov 24, 2023
Merged via the queue into develop with commit 704c125 Nov 24, 2023
25 checks passed
@mathemancer mathemancer deleted the connections_model branch November 24, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Implement new "connections" model and API
4 participants