-
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
fix: CSV upload with overprescribed table/schema #18758
fix: CSV upload with overprescribed table/schema #18758
Conversation
d323067
to
44154f5
Compare
fa8907e
to
08e94bd
Compare
Codecov Report
@@ Coverage Diff @@
## master #18758 +/- ##
==========================================
- Coverage 66.31% 66.15% -0.16%
==========================================
Files 1620 1620
Lines 63080 63066 -14
Branches 6370 6370
==========================================
- Hits 41832 41722 -110
- Misses 19591 19687 +96
Partials 1657 1657
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
message = _( | ||
"You cannot specify a namespace both in the name of the table: " | ||
'"%(csv_table.table)s" and in the schema field: ' |
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.
This was the initial error. The csv_table.table
and csv_table.schema
variables are not inputs to the function.
ca21d93
to
c1c0fb6
Compare
c1c0fb6
to
fef15bc
Compare
superset/views/database/views.py
Outdated
@@ -130,24 +130,29 @@ def form_get(self, form: CsvToDatabaseForm) -> None: | |||
|
|||
def form_post(self, form: CsvToDatabaseForm) -> Response: | |||
database = form.con.data | |||
csv_table = Table(table=form.name.data, schema=form.schema.data) | |||
|
|||
if "." in form.name.data: |
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.
This is a detail, but I think it is worth moving the format checking to a separate method / function, so that the name of the method says what you really want to check and hide the implementations here to improve readability. It currently says you want to check if it contains a period, but in fact you are checking to see if it contains a namespace.
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.
@ad-m I've restructured the PR using an alternative formulation.
cb23f8c
to
351500d
Compare
85da944
to
41264a5
Compare
41264a5
to
7f2df47
Compare
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.
Can we add a test to make sure this bit ends up being covered?
7f2df47
to
7ad0d42
Compare
@craig-rueda I initially (and wrongfully) thought the WTForms validation logic was all frontend and would be difficult to capture in a unit test but it's all server side and thus a backend unit test is viable. I've added the test as requested. |
7ad0d42
to
a424b6d
Compare
SUMMARY
This PR fixes a couple of issues related to CSV upload:
I debated how best to tackle this and initially went down the route of redefining the server-side form post logic (with unit tests), but opted for hopefully an easier/cleaner route by adding form validators.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Tested locally.
ADDITIONAL INFORMATION