You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/07/06 23:56:38 UTC

[PR] test(models): prove owner association tables reject duplicate rows [superset]

rusackas opened a new pull request, #41837:
URL: https://github.com/apache/superset/pull/41837

   ### SUMMARY
   Test-only PR — no production code changes.
   
   Issue #41623 reported that the three owner association tables (`dashboard_user`, `slice_user`, `sqlatable_user`) lacked a uniqueness guarantee on `(user_id, <resource>_id)`, letting duplicate owner rows accumulate and silently break owner removal (HTTP 422).
   
   That gap was fixed on master by #39859 (merged 2026-07-01, hours after the issue was filed), which replaced the surrogate `id` PK with a composite `(user_id, <resource>_id)` primary key on all M2M association tables. This PR adds a regression test that pins the contract the issue asked for, directly against the live ORM `Table` objects:
   
   - each of the three owner tables declares a primary key covering exactly `(user_id, <resource>_id)`
   - inserting the same (user, resource) pair twice raises `IntegrityError` (in-memory SQLite)
   - distinct pairs still insert fine (uniqueness is over the pair, not a single column)
   
   The existing coverage from #39859 (`tests/unit_tests/migrations/composite_pk_association_tables_test.py`) rebuilds the post-migration schema *synthetically* and notes it "does not reflect the live ORM models" — so a regression in the model definitions themselves would slip past it. This test closes that gap.
   
   The test passes on current master, confirming the issue is resolved.
   
   closes #41623
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A — test-only change.
   
   ### TESTING INSTRUCTIONS
   ```bash
   pytest tests/unit_tests/models/owner_association_tables_test.py -q
   ```
   All 9 tests (3 assertions × 3 tables) should pass.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: closes #41623
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(models): prove owner association tables reject duplicate rows [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #41837:
URL: https://github.com/apache/superset/pull/41837#issuecomment-4898721333

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/41837?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 55.99%. Comparing base ([`9e50d9e`](https://app.codecov.io/gh/apache/superset/commit/9e50d9eca674c8bcd033e6617fcb7943cd02e252?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`02c0b39`](https://app.codecov.io/gh/apache/superset/commit/02c0b39ec8ca480a87174569a1aa1ad61661ce73?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   > :exclamation:  There is a different number of reports uploaded between BASE (9e50d9e) and HEAD (02c0b39). Click for more details.
   > 
   > <details><summary>HEAD has 24 uploads less than BASE</summary>
   >
   >| Flag | BASE (9e50d9e) | HEAD (02c0b39) |
   >|------|------|------|
   >|python|22|2|
   >|presto|3|1|
   >|hive|3|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #41837      +/-   ##
   ==========================================
   - Coverage   64.78%   55.99%   -8.79%     
   ==========================================
     Files        2689     2689              
     Lines      148936   148936              
     Branches    34365    34365              
   ==========================================
   - Hits        96481    83391   -13090     
   - Misses      50690    64793   +14103     
   + Partials     1765      752    -1013     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.20% <ø> (ø)` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.73% <ø> (ø)` | |
   | [python](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.79% <ø> (-18.54%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/41837/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/41837?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(models): prove owner association tables reject duplicate rows [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41837:
URL: https://github.com/apache/superset/pull/41837#issuecomment-4898698532

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(models): prove owner association tables reject duplicate rows [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #41837:
URL: https://github.com/apache/superset/pull/41837


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org