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

[database] Fix, tables endpoint #9144

Merged
merged 14 commits into from Feb 20, 2020

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Feb 14, 2020

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Adds database filter to /superset/tables. Took the chance to add typing, improved parameter validation and tests

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@willbarrett

@codecov-io
Copy link

codecov-io commented Feb 17, 2020

Codecov Report

Merging #9144 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9144   +/-   ##
=======================================
  Coverage   59.06%   59.06%           
=======================================
  Files         372      372           
  Lines       11922    11922           
  Branches     2919     2919           
=======================================
  Hits         7042     7042           
  Misses       4698     4698           
  Partials      182      182
Impacted Files Coverage Δ
...frontend/src/dashboard/components/MissingChart.jsx 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63f4f00...f1993ea. Read the comment docs.

@dpgaspar dpgaspar marked this pull request as ready for review February 17, 2020 17:14
@dpgaspar dpgaspar requested review from villebro, john-bodley and etr2460 and removed request for villebro and john-bodley February 18, 2020 11:56
Copy link
Member

@willbarrett willbarrett left a comment

Choose a reason for hiding this comment

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

I think this should be 2 PRs - one implementing the security fix on the current endpoint, and a second migrating the endpoint to the new API. We're mixing concerns, and I think the migration to the new API will require a rework of the code.

superset/views/core.py Outdated Show resolved Hide resolved
superset/views/core.py Outdated Show resolved Hide resolved
superset/views/database/api.py Outdated Show resolved Hide resolved
@protect()
@safe
@event_logger.log_this
def tables( # pylint: disable=invalid-name,too-many-locals
Copy link
Member

Choose a reason for hiding this comment

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

I'm starting to wonder if we want to do this migration now as part of the security fix PR? This looks like we've pulled the method definition over almost as-is, but as pylint is showing us, this really could use a refactor. Would it be better to have one PR that adds the security fix, then a second that refactors the method into the new API?

Another approach here could be to "strangle" the current implementation by proxying to the current implementation, then refactoring it over time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed I'll break this into 2 PR's

@dpgaspar dpgaspar changed the title [database] Fix, tables endpoint [WiP] [database] Fix, tables endpoint Feb 18, 2020
@dpgaspar dpgaspar changed the title [WiP] [database] Fix, tables endpoint [database] Fix, tables endpoint Feb 19, 2020
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

I agree with @willbarrett , much better to have the original PR split up as separate PRs.

Comment on lines +1068 to +1070
database = query.filter_by(id=db_id).one_or_none()
if not database:
return json_error_response("Not found", 404)
Copy link
Member

Choose a reason for hiding this comment

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

Did we settle for try-except with .one() or .one_or_none() with if not? I'm fine either way, just prefer to have it as uniform as possible in the codebase.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a majority of one_or_none() on core.py

@dpgaspar dpgaspar merged commit e55fe43 into apache:master Feb 20, 2020
@dpgaspar dpgaspar deleted the fix/superset-tables-api branch February 20, 2020 10:15
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants