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

feat(database): POST, PUT, DELETE API endpoints #10741

Merged
merged 18 commits into from
Sep 2, 2020

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Aug 31, 2020

SUMMARY

Creates REST API endpoints for Database POST, PUT and DELETE

Screenshot 2020-09-01 at 17 07 42

Screenshot 2020-09-01 at 17 08 29

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

Comment on lines +71 to +88
show_columns = [
"id",
"database_name",
"cache_timeout",
"expose_in_sqllab",
"allow_run_async",
"allow_csv_upload",
"allow_ctas",
"allow_cvas",
"allow_dml",
"force_ctas_schema",
"allow_multi_schema_metadata_fetch",
"impersonate_user",
"encrypted_extra",
"extra",
"server_cert",
"sqlalchemy_uri",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add all these fields to list_columns as well? Most of them are already included anyway, so it would save a GET request when opening the edit modal.

Copy link
Member Author

@dpgaspar dpgaspar Sep 1, 2020

Choose a reason for hiding this comment

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

I can do that, but I would prefer not to wire the whole detail payload for all the databases. Users will probably edit very few database connections, but will probably search, sort etc much more.
The cost for a get operation by a primary key is low also

from superset.extensions import security_manager
from superset.models.core import Database
from superset.typing import FlaskResponse
from superset.utils.core import error_msg_from_exception
from superset.views.base_api import BaseSupersetModelRestApi, statsd_metrics
from superset.views.database.filters import DatabaseFilter
from superset.views.database.validators import sqlalchemy_uri_validator
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this to superset/databases/utils.py since they are utility/helper functions

database = DatabaseDAO.create(self._properties, commit=False)
database.set_sqlalchemy_uri(database.sqlalchemy_uri)
# adding a new database we always want to force refresh schema list
# TODO Improve this simplistic implementation for catching DB conn fails
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: Since we need to fetch db schemas to create schema permissions, we need valid/working connections when creating a database, made a simplistic approach to this, since this PR was already big.

@lilykuang we could move db test connection logic into a command

@@ -1,268 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
Copy link
Member

Choose a reason for hiding this comment

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

Let's remember to use git mv to retain history.

@dpgaspar dpgaspar closed this Sep 1, 2020
@dpgaspar dpgaspar reopened this Sep 1, 2020
@codecov-commenter
Copy link

Codecov Report

Merging #10741 into master will increase coverage by 2.56%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10741      +/-   ##
==========================================
+ Coverage   58.92%   61.49%   +2.56%     
==========================================
  Files         756      429     -327     
  Lines       36072    13954   -22118     
  Branches     3301     3555     +254     
==========================================
- Hits        21256     8581   -12675     
+ Misses      14633     5186    -9447     
- Partials      183      187       +4     
Flag Coverage Δ
#cypress ?
#javascript 61.49% <ø> (?)
#python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/views/App.tsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/SqlLab/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/views/menu.tsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/views/index.tsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/SqlLab/index.tsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/App.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/explore/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/dashboard/index.jsx 0.00% <0.00%> (-100.00%) ⬇️
superset-frontend/src/setup/setupColors.js 0.00% <0.00%> (-100.00%) ⬇️
... and 673 more

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 234b6bb...0047e77. Read the comment docs.

@dpgaspar dpgaspar marked this pull request as ready for review September 1, 2020 23:58
@willbarrett willbarrett merged commit 77a3167 into apache:master Sep 2, 2020
@willbarrett willbarrett deleted the feat/database-api-mut branch September 2, 2020 17:03
amitmiran137 pushed a commit to ofekisr/incubator-superset that referenced this pull request Sep 7, 2020
…boards_permissions

* upstream/master: (32 commits)
  docs: Add a note to contributing.md on reporting security vulnerabilities (apache#10796)
  Fix: Include RLS filters for cache keys (apache#10805)
  feat: filters for database list view (apache#10772)
  fix: MVC show saved query (apache#10781)
  added creator column and adjusted order columns (apache#10789)
  security: disallow uuid package on jinja2 (apache#10794)
  feat: CRUD REST API for saved queries (apache#10777)
  fix: disable domain sharding on explore view (apache#10787)
  fix: can not type `0.05` in `TextControl` (apache#10778)
  fix: pivot table timestamp grouping (apache#10774)
  fix: add validator information to email/slack alerts (apache#10762)
  More Label touchups (margins) (apache#10722)
  fix: dashboard extra filters (apache#10692)
  fix: re-installing local superset in cache image (apache#10766)
  feat: SIP-34 table list view for databases (apache#10705)
  refactor: convert DatasetList schema filter to use new distinct api (apache#10746)
  chore: removing fsevents dependency (apache#10751)
  Fix precommit hook for docs/installation.rst (apache#10759)
  feat(database): POST, PUT, DELETE API endpoints (apache#10741)
  docs: Update OAuth configuration in installation.rst (apache#10748)
  ...
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* feat(database): POST, PUT, DELETE API endpoints

* post tests

* more tests

* lint

* lint

* debug ci

* fix test

* fix test

* fix test

* fix test

* fix test

* fix test

* cleanup

* handle db connection failures

* lint

* skip hive and presto for connection fail test

* fix typo
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.0 labels Mar 12, 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 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants