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

Implement schemas.delete RPC method #3610

Merged
merged 5 commits into from
Jun 5, 2024
Merged

Implement schemas.delete RPC method #3610

merged 5 commits into from
Jun 5, 2024

Conversation

seancolsen
Copy link
Contributor

Fixes #3609

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.

@seancolsen seancolsen added this to the Beta milestone May 29, 2024
@seancolsen seancolsen added the pr-status: review A PR awaiting review label May 29, 2024
@seancolsen
Copy link
Contributor Author

@mathemancer heads up that test_get_valid_target_type_strings (an SQL test you wrote in d44c0b8 in #3556) was being flaky for me, including in CI. Sometimes it was passing. Sometimes it was failing with this error:

# Subtest: public.test_get_valid_target_type_strings()
    not ok 1
    # Failed test 1
    #         have: ["text", "numeric"]
    #         want: ["numeric", "text"]
    not ok 2
    # Failed test 2
    #         have: ["text", "numeric"]
    #         want: ["numeric", "text"]
    ok 3
    1..3
    # Looks like you failed 2 tests of 3
not ok 94 - public.test_get_valid_target_type_strings

I fixed the test in 529ffef by making the assertions order-independent. That commit is unrelated to this PR, but I tacked it on here for simplicity's sake. I'm happy to cherry pick this into a separate PR if you prefer. I wouldn't be surprised if we see this flakiness crop up in other PRs until we merge this fix.

@mathemancer mathemancer self-requested a review June 4, 2024 08:23
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

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

Looks good overall. The only change to request is the argument order of the RPC function.

Comment on lines +4 to +22
def drop_schema_via_name(engine, name, cascade=False):
"""
Drop a schema.
Drop a schema by its name.

If no schema exists with the given name, an exception will be raised.

Deprecated:
Use drop_schema_via_oid instead. This function is deprecated because we
are phasing out name-based operations in favor of OID-based operations
and we are phasing out SQLAlchemy in favor of psycopg.

Args:
schema_name: Name of the schema to drop.
engine: SQLAlchemy engine object for connecting.
cascade: Whether to drop the dependent objects.
if_exists: Whether to ignore an error if the schema doesn't
exist.
engine: SQLAlchemy engine object for connecting. name: Name of the
schema to drop. cascade: Whether to drop the dependent objects.
"""
execute_msar_func_with_engine(engine, 'drop_schema', name, cascade).fetchone()


Returns:
Returns a string giving the command that was run.
def drop_schema_via_oid(conn, id, cascade=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

It's debatable whether the specific name drop_schema_via_oid will be relevant once drop_schema_via_name is removed when the model is removed. However, I don't think we need to agree on or change this detail to merge this PR.

@rpc_method(name="schemas.delete")
@http_basic_auth_login_required
@handle_rpc_exceptions
def delete(*, database_id: int, schema_id: int, **kwargs) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def delete(*, database_id: int, schema_id: int, **kwargs) -> None:
def delete(*, schema_id: int, database_id: int, **kwargs) -> None:

I think we should switch this arg order to match the other RPC functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ea51de0

@seancolsen
Copy link
Contributor Author

Ready for re-review @mathemancer

Base automatically changed from architectural_overhaul to develop June 4, 2024 15:36
@mathemancer mathemancer self-requested a review June 5, 2024 05:49
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

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

Okay, this looks great. Thank you!

@mathemancer mathemancer added this pull request to the merge queue Jun 5, 2024
Merged via the queue into develop with commit 63a82f0 Jun 5, 2024
37 checks passed
@mathemancer mathemancer deleted the schemas_delete branch June 5, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants