Skip to content

Add 210 behavioral tests and fix data safety regressions - #194

Merged
jogibear9988 merged 1 commit into
masterfrom
codex/useful-coverage-expansion
Sep 23, 2026
Merged

jogibear9988 merged 1 commit into
masterfrom
codex/useful-coverage-expansion

Conversation

@jogibear9988

Copy link
Copy Markdown
Member

Summary

Add 210 behavioral test cases for previously uncovered database operations and fix the defects they expose. Assertions verify persisted rows, schema constraints, rollback, typed parameters, and resource ownership.

Fixes exposed by the tests

  • Delete safety: missing predicate values could turn a filtered delete into a whole-table delete. Missing, empty, and mismatched predicate arrays now throw before execution. Null predicates use IS NULL, with correct binding for other values.
  • Joined views: group fields by relationship, assign distinct aliases, qualify base-table columns, and honor parent aliases in chained joins. Cover multiple fields per relationship and multiple relationships to the same table.
  • SQLite fallback rename: rebuild the parent and dependent tables atomically before checking foreign-key integrity. Update self-references, preserve caller transactions, and roll back the parent rename if a dependent table cannot be rebuilt.
  • SQLite foreign-key removal: implement the previously ineffective column-specific operation for incoming and outgoing references. Preserve unrelated constraints and data, restore foreign-key settings, and roll back all affected tables on failure.

Added test coverage

  • Real SQLite schema lifecycles, defaults, constraints, views, copy/update operations, scripts, and failure recovery.
  • Parameter types and numeric/time boundaries, transaction enlistment, disposal on failure, and borrowed connection ownership.
  • Invalid copy/update requests rejected before writes across SQL Server, Oracle, PostgreSQL, and SQLite.
  • MySQL/MariaDB metadata conversion and constraint-removal contracts, nullable record conversions, and logging behavior.

Validation

1,100 Unit + SQLite tests passed; 0 failures and 0 skips. git diff --check passed.

Same-filter Coverlet comparison against b540baf, using unchanged .github/coverage.runsettings:

Metric Before After Change
Lines 48.14% (5,047/10,484) 56.13% (5,918/10,543) +7.99 percentage points
Branches 41.22% (2,132/5,172) 49.87% (2,608/5,230) +8.64 percentage points
Passing tests 890 1,100 +210

These are local Unit + SQLite results, not the combined database coverage figure of approximately 80%. The full database CI matrix must establish the new combined percentage. No coverage exclusions were added. Provider contract tests supplement live engine validation.

$filter = 'TestCategory!=SQLServer&TestCategory!=PostgreSQL&TestCategory!=Oracle&TestCategory!=MySQL&TestCategory!=MariaDB&TestCategory!=Firebird&TestCategory!=Db2&TestCategory!=Informix&TestCategory!=Sybase&TestCategory!=Hana'
dotnet test src/Migrator.Tests/Migrator.Tests.csproj --filter $filter --collect 'XPlat Code Coverage' --settings .github/coverage.runsettings -- NUnit.NumberOfTestWorkers=0

Compatibility

Malformed structured delete predicates now throw argument exceptions instead of silently deleting all rows or reaching the database. Intentional whole-table deletion remains supported by omitting both predicate arrays.

Add 210 test cases for actual SQLite data/schema changes, provider command
contracts, data-transfer validation, metadata decoding, logging, and nullable
record conversions. Verify persisted rows, constraint definitions, rollback,
parameter types, reader/command disposal, and borrowed connection ownership.

Fix defects exposed by the new tests:
- Group view fields by relationship, assign distinct join aliases, qualify
  base-table columns, and honor explicit parent aliases in chained joins.
- Generate IS NULL predicates for parameterized deletes and reject missing,
  empty, or mismatched predicate arrays before SQL execution. Missing values
  must never turn a filtered delete into a whole-table delete.
- Rebuild SQLite fallback column renames and their dependent tables in one
  transaction, update self-referencing keys, and preserve caller transactions.
- Implement atomic SQLite removal of incoming/outgoing foreign keys for a
  column, preserving unrelated constraints and restoring foreign-key settings.

Validation: all 1,100 Unit + SQLite tests pass, with no failures or skips;
git diff --check passes. Same-filter Coverlet comparison against b540baf:
- Line coverage: 48.14% (5,047/10,484) -> 56.13% (5,918/10,543).
- Branch coverage: 41.22% (2,132/5,172) -> 49.87% (2,608/5,230).
- Passing tests: 890 -> 1,100.

Coverage configuration and exclusions are unchanged. These local results
exclude external database suites; the full CI matrix must establish the new
combined coverage percentage. MySQL/MariaDB metadata and cross-provider SQL
contract tests supplement, rather than replace, live engine validation.
Copilot AI lite review requested due to automatic review settings September 23, 2026 15:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jogibear9988
jogibear9988 merged commit a0095d9 into master Sep 23, 2026
26 of 27 checks passed
@jogibear9988
jogibear9988 deleted the codex/useful-coverage-expansion branch September 23, 2026 15:36
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.

2 participants