-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: deprecate /superset/extra_table_metadata migrate to api v1 #19921
Merged
dpgaspar
merged 7 commits into
apache:master
from
preset-io:danielgaspar/sc-42066/migrate-superset-extra-table-metadata-database
May 4, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
802cab2
feat: deprecate /superset/extra_table_metadata migrate to api v1
dpgaspar 8066b25
use can_read to table_extra_metadata
dpgaspar eaa4e6a
troubleshoot sqlite
dpgaspar 59ed3b3
fix test
dpgaspar 626f7e8
fix test
dpgaspar 844719d
fix test
dpgaspar 5e0ee01
fix frontend test on sqllab
dpgaspar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -415,10 +415,10 @@ describe('async actions', () => { | |||||
fetchMock.delete(updateTableSchemaEndpoint, {}); | ||||||
fetchMock.post(updateTableSchemaEndpoint, JSON.stringify({ id: 1 })); | ||||||
|
||||||
const getTableMetadataEndpoint = 'glob:*/api/v1/database/*'; | ||||||
const getTableMetadataEndpoint = 'glob:**/api/v1/database/*/table/*/*/'; | ||||||
fetchMock.get(getTableMetadataEndpoint, {}); | ||||||
const getExtraTableMetadataEndpoint = | ||||||
'glob:*/superset/extra_table_metadata/*'; | ||||||
'glob:**/api/v1/database/*/table_extra/*/*/'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Suggested change
|
||||||
fetchMock.get(getExtraTableMetadataEndpoint, {}); | ||||||
|
||||||
let isFeatureEnabledMock; | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -775,10 +775,30 @@ def test_get_invalid_table_table_metadata(self): | |
Database API: Test get invalid table from table metadata | ||
""" | ||
example_db = get_example_database() | ||
uri = f"api/v1/database/{example_db.id}/wrong_table/null/" | ||
uri = f"api/v1/database/{example_db.id}/table/wrong_table/null/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
self.login(username="admin") | ||
rv = self.client.get(uri) | ||
self.assertEqual(rv.status_code, 404) | ||
data = json.loads(rv.data.decode("utf-8")) | ||
if example_db.backend == "sqlite": | ||
self.assertEqual(rv.status_code, 200) | ||
self.assertEqual( | ||
data, | ||
{ | ||
"columns": [], | ||
"comment": None, | ||
"foreignKeys": [], | ||
"indexes": [], | ||
"name": "wrong_table", | ||
"primaryKey": {"constrained_columns": None, "name": None}, | ||
"selectStar": "SELECT\nFROM wrong_table\nLIMIT 100\nOFFSET 0", | ||
}, | ||
) | ||
elif example_db.backend == "mysql": | ||
self.assertEqual(rv.status_code, 422) | ||
self.assertEqual(data, {"message": "`wrong_table`"}) | ||
else: | ||
self.assertEqual(rv.status_code, 422) | ||
self.assertEqual(data, {"message": "wrong_table"}) | ||
|
||
def test_get_table_metadata_no_db_permission(self): | ||
""" | ||
|
@@ -790,6 +810,46 @@ def test_get_table_metadata_no_db_permission(self): | |
rv = self.client.get(uri) | ||
self.assertEqual(rv.status_code, 404) | ||
|
||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") | ||
def test_get_table_extra_metadata(self): | ||
""" | ||
Database API: Test get table extra metadata info | ||
""" | ||
example_db = get_example_database() | ||
self.login(username="admin") | ||
uri = f"api/v1/database/{example_db.id}/table_extra/birth_names/null/" | ||
rv = self.client.get(uri) | ||
self.assertEqual(rv.status_code, 200) | ||
response = json.loads(rv.data.decode("utf-8")) | ||
self.assertEqual(response, {}) | ||
|
||
def test_get_invalid_database_table_extra_metadata(self): | ||
""" | ||
Database API: Test get invalid database from table extra metadata | ||
""" | ||
database_id = 1000 | ||
self.login(username="admin") | ||
uri = f"api/v1/database/{database_id}/table_extra/some_table/some_schema/" | ||
rv = self.client.get(uri) | ||
self.assertEqual(rv.status_code, 404) | ||
|
||
uri = "api/v1/database/some_database/table_extra/some_table/some_schema/" | ||
rv = self.client.get(uri) | ||
self.assertEqual(rv.status_code, 404) | ||
|
||
def test_get_invalid_table_table_extra_metadata(self): | ||
""" | ||
Database API: Test get invalid table from table extra metadata | ||
""" | ||
example_db = get_example_database() | ||
uri = f"api/v1/database/{example_db.id}/table_extra/wrong_table/null/" | ||
self.login(username="admin") | ||
rv = self.client.get(uri) | ||
data = json.loads(rv.data.decode("utf-8")) | ||
|
||
self.assertEqual(rv.status_code, 200) | ||
self.assertEqual(data, {}) | ||
dpgaspar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") | ||
def test_get_select_star(self): | ||
""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't a single asterisk here sufficient?