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(reports): make name unique between alerts and reports #12196

Merged
merged 5 commits into from
Dec 24, 2020

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Dec 23, 2020

SUMMARY

Uniqueness was being imposed on Alerts/Report names, preventing user's from creating an Alert name "X" and a Report with the same name "X". This allows it while still enforcing name uniqueness on Alerts and Reports separately

Also guarantees that a database reference is not sent when creating a report

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

@dpgaspar dpgaspar added risk:db-migration PRs that require a DB migration and removed size/M labels Dec 23, 2020
@dpgaspar dpgaspar requested a review from villebro December 23, 2020 12:50
@pull-request-size pull-request-size bot added size/L and removed size/M labels Dec 23, 2020
@codecov-io
Copy link

codecov-io commented Dec 23, 2020

Codecov Report

Merging #12196 (ead35b3) into master (93af329) will decrease coverage by 0.22%.
The diff coverage is 32.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12196      +/-   ##
==========================================
- Coverage   63.06%   62.84%   -0.23%     
==========================================
  Files         994      995       +1     
  Lines       49075    49106      +31     
  Branches     4984     4983       -1     
==========================================
- Hits        30950    30861      -89     
- Misses      17925    18045     +120     
  Partials      200      200              
Flag Coverage Δ
javascript 61.20% <ø> (-0.03%) ⬇️
python 63.90% <32.43%> (-0.36%) ⬇️

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

Impacted Files Coverage Δ
...ns/c878781977c6_alert_reports_shared_uniqueness.py 0.00% <0.00%> (ø)
superset/reports/commands/exceptions.py 98.55% <ø> (ø)
superset/reports/commands/update.py 89.85% <50.00%> (ø)
superset/models/reports.py 100.00% <100.00%> (ø)
superset/reports/commands/create.py 87.27% <100.00%> (ø)
superset/reports/dao.py 79.24% <100.00%> (ø)
superset/reports/schemas.py 98.59% <100.00%> (+0.10%) ⬆️
superset/sql_validators/postgres.py 50.00% <0.00%> (-50.00%) ⬇️
superset/db_engine_specs/mysql.py 79.59% <0.00%> (-12.25%) ⬇️
superset/db_engine_specs/sqlite.py 65.62% <0.00%> (-9.38%) ⬇️
... and 23 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 93af329...ead35b3. Read the comment docs.

@dpgaspar dpgaspar requested a review from nytai December 23, 2020 17:35

else:
with op.batch_alter_table(
"report_schedule", copy_from=report_schedule
Copy link
Member Author

Choose a reason for hiding this comment

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

This was required to remove UNIQUE (name) that is not an actual constraint from SQLite

Copy link
Member

@nytai nytai left a comment

Choose a reason for hiding this comment

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

LGTM. SQLite constraints are such a pain to deal with, we should consider dropping official support for it soon.

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!

Comment on lines +95 to +100
with op.batch_alter_table(
"report_schedule", copy_from=report_schedule
) as batch_op:
batch_op.create_unique_constraint(
"uq_report_schedule_name_type", ["name", "type"]
)
Copy link
Member

Choose a reason for hiding this comment

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

This took a loong while for me to wrap my head around 😆 A small comment here could be really helpful for the next person trying to understand what's going on.

@dpgaspar dpgaspar merged commit 74f3faf into apache:master Dec 24, 2020
@dpgaspar dpgaspar deleted the fix/alerts-uniqueness branch December 24, 2020 09:18
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.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 risk:db-migration PRs that require a DB migration size/L 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants