Skip to content

Make reverse-engineered SQL test delete steps fail when nothing is deleted. #10901 - #10902

Merged
dpage merged 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10901-resql-delete-check
Nov 30, 2026
Merged

dpage merged 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10901-resql-delete-check

Conversation

@dpage

@dpage dpage commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The resql runner (web/regression/re_sql/tests/test_resql.py) now keeps the schema id from the last create scenario that named a schema, rather than resetting it to the default test schema for child objects such as constraints, and fails a delete step whose response has success set to 0 (pgAdmin returns HTTP 200 with "Object not found").
  • Fixed the test data that the stricter check exposed:
    • foreign keys (default, 18_plus): removed a duplicated "Drop Foreign Key" step, and dropped the second table by id and the first by name through NODE-table.delete, since a delete_id table step always targets the last stored table.
    • indexes (default, 15_plus): "Drop Table" ran before the last index create and delete; moved it to the end. It only appeared to work before because it was silently hitting the wrong schema.
    • views (all pg and ppas tests.json): "Drop Table for view" used the view's id; the table create now stores its id.

Test plan

  • runtests.py --pkg resql on PostgreSQL 18 (local), 14, 15, 16 and 17 (Docker): all pass, and the changed drop steps run and report ok on each.
  • EPAS (ppas) files were changed in the same way but not run locally.

Closes #10901

Summary by CodeRabbit

  • Tests
    • Improved database test reliability by preserving the selected schema for related objects and detecting unsuccessful deletions, including responses that otherwise appear successful.
    • Updated foreign-key and index test cleanup sequences to remove tables in a consistent order.
    • Updated view-creation scenarios to retain the created table’s identity across supported database versions.

…leted. pgadmin-org#10901

The resql runner reset the schema id to the default test schema for any
create scenario without a schema, so a delete after creating a child object
(such as a foreign key) used the wrong schema. It also only checked for an
HTTP 200 from delete, which pgAdmin returns with success set to 0 when the
object is not found.

Keep the schema id from the last create that named one, and fail a delete
step whose response has success set to 0. Fix the test data this exposed:
a duplicated foreign key drop, tables dropped in an order the runner could
not target, an index test that dropped its table before its last step, and
view tests that dropped their table using the view's id.

Closes pgadmin-org#10901
@dpage dpage self-assigned this Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The ReSQL test runner retains the selected schema across create scenarios without a schema field and checks delete response success. Test fixtures enable object ID storage and update table and foreign-key cleanup steps.

Changes

ReSQL test scenarios

Layer / File(s) Summary
Scenario setup and cleanup
web/.../schemas/views/tests/{pg,ppas}/*/tests.json, web/.../constraints/foreign_key/tests/{default,18_plus}/test_foreign_keys.json, web/.../indexes/tests/{default,15_plus}/test_indexes.json
View table scenarios now set store_object_id to true. Foreign-key cleanup removes a trailing delete scenario, deletes the second table before the first, and changes the first-table delete request. Index scenarios move table deletion after index deletion.
Schema retention and delete validation
web/regression/re_sql/tests/test_resql.py
The runner initializes schema_id from the default schema and retains the current value when a create scenario omits schema. Delete scenarios now fail when the response JSON reports success as 0.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Other · Severity of issue fixed: Low

Possibly related PRs

  • pgadmin-org/pgadmin4#10883: Adds PostgreSQL 18+ foreign-key test scenarios and changes trailing table-delete steps in the same test area.
  • pgadmin-org/pgadmin4#10885: Adds PostgreSQL 18 PERIOD foreign-key tests and uses SQL for cleanup where table-delete steps could not find the tables.
Merge Risk: Minimal · up to 303be

This change makes the reverse-engineered SQL tests fail when a delete step does not delete anything, and it fixes the test data that this stricter check exposed. It affects only the test suite, not production behavior. No merge-blocking risk remains. The EPAS fixtures were not run locally.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main behavioral change: reverse-engineered SQL test delete steps now fail when a delete removes nothing. The raw summary shows the core change in test_resql.py checks the delete r…
Linked Issues check Passed Issue #10901 has two coding requirements. (1) Keep the schema ID from the last create that set one. The diff in web/regression/re_sql/tests/test_resql.py removes the `else: self.schema_id = self.serve…
Out of Scope Changes check Passed All changed files are test infrastructure or test data under web/regression/re_sql and the reverse-engineered SQL test folders for foreign keys, indexes, and views. The test data edits are the fixes t…
Full details: Title check

Explanation

The title states the main behavioral change: reverse-engineered SQL test delete steps now fail when a delete removes nothing. The raw summary shows the core change in test_resql.py checks the delete response's success value and the test data was adjusted accordingly, and the objectives confirm this matches the linked issue #10901. The title is concise and specific, and it includes an issue reference.

Full details: Linked Issues check

Explanation

Issue #10901 has two coding requirements. (1) Keep the schema ID from the last create that set one. The diff in web/regression/re_sql/tests/test_resql.py removes the else: self.schema_id = self.server_information['schema_id'] branch from check_schema_precondition(), so a create scenario without schema no longer resets the schema ID. execute_test_case() also initializes schema_id to the default schema at the start of each test file. (2) Check the success value of the delete response. The diff adds a check that fails the step when the JSON success value is 0 and reports errormsg. Both requirements are implemented in the reviewed head. The test-data fixes named in the issue (foreign key, index, and view tests under the pg, ppas, default, 15_plus, 16_plus, 17_plus, and 18_plus folders) are described in the PR summary and the AI-generated file summaries. I did not inspect those JSON hunks, so their exact content is not verified. The runner changes that the issue requires are verified in source.

Full details: Out of Scope Changes check

Explanation

All changed files are test infrastructure or test data under web/regression/re_sql and the reverse-engineered SQL test folders for foreign keys, indexes, and views. The test data edits are the fixes the issue asks for: removing the duplicate Drop Foreign Key step, moving Drop Table after the index deletions, and storing the table id for view tests. The stricter success check exposed these problems. No product code, documentation, or unrelated module is changed. The JSON hunks were judged from the summaries and were not read directly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2386a2b and 303be47.

Files selected for processing: 13

  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/18_plus/test_foreign_keys.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/test_foreign_keys.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/15_plus/test_indexes.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/tests/default/test_indexes.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/16_plus/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/17_plus/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/16_plus/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/17_plus/tests.json
  • web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/tests.json
  • web/regression/re_sql/tests/test_resql.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@dpage
dpage merged commit 5d88433 into pgadmin-org:master Nov 30, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reverse-engineered SQL test delete steps can silently fail to delete anything

1 participant