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

fix: allow db driver distinction on enforced URI params #23769

Merged
merged 1 commit into from
Apr 23, 2023

Conversation

dpgaspar
Copy link
Member

SUMMARY

Parameters on SQLAlchemy URI vary by driver. Currently connections using "mysql+mysqlconnector" break because the engine spec is enforcing an unknown parameter for this driver.

This PR fixes this issue introducing the driver name to disallow_uri_query_params and enforce_uri_query_params

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

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.

LGTM with an optional thought

Comment on lines -178 to +185
disallow_uri_query_params = {"local_infile"}
enforce_uri_query_params = {"local_infile": 0}
disallow_uri_query_params = {
"mysqldb": {"local_infile"},
"mysqlconnector": {"allow_local_infile"},
}
enforce_uri_query_params = {
"mysqldb": {"local_infile": 0},
"mysqlconnector": {"allow_local_infile": 0},
}
Copy link
Member

Choose a reason for hiding this comment

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

thinking out loud: would it be convenient to be able to specify globally disallowed params, too? Something like this:

    disallow_uri_query_params = {
        "": {"my_globally_disallowed_param"},
        "mysqldb": {"local_infile"},
        "mysqlconnector": {"allow_local_infile"},
    }

(feel free to ignore this idea, as it looks pretty awful 😆)

@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Merging #23769 (c0b48e3) into master (0b43112) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

❗ Current head c0b48e3 differs from pull request most recent head fc00575. Consider uploading reports for the commit fc00575 to get more accurate results

@@            Coverage Diff             @@
##           master   #23769      +/-   ##
==========================================
- Coverage   67.87%   67.83%   -0.04%     
==========================================
  Files        1924     1924              
  Lines       74379    74381       +2     
  Branches     8106     8106              
==========================================
- Hits        50484    50457      -27     
- Misses      21818    21847      +29     
  Partials     2077     2077              
Flag Coverage Δ
hive 52.92% <62.50%> (-0.01%) ⬇️
mysql 78.74% <75.00%> (-0.01%) ⬇️
postgres ?
presto 52.84% <62.50%> (-0.01%) ⬇️
python 82.57% <100.00%> (-0.08%) ⬇️
sqlite 77.31% <75.00%> (-0.01%) ⬇️
unit 52.72% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/db_engine_specs/base.py 90.82% <100.00%> (+0.02%) ⬆️
superset/db_engine_specs/mysql.py 98.82% <100.00%> (ø)

... and 12 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dpgaspar dpgaspar merged commit 6ae5388 into apache:master Apr 23, 2023
@dpgaspar dpgaspar deleted the fix/mysql-disallow-param branch April 23, 2023 14:44
sebastianliebscher pushed a commit to sebastianliebscher/superset that referenced this pull request Apr 28, 2023
eschutho pushed a commit that referenced this pull request May 25, 2023
eschutho added a commit that referenced this pull request May 30, 2023
@mistercrunch mistercrunch added 🍒 2.1.1 🍒 2.1.2 🍒 2.1.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v2.1 🍒 2.1.1 🍒 2.1.2 🍒 2.1.3 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants