refactor(dedup): IQueryBreakdownCollectionView eliminates Markdown adapter classes #23

Merged
bermudalamb merged 1 commits from chore/sonarqube-src-dedup-final into main 2026-05-29 13:52:00 -05:00
1 Commits
Author SHA1 Message Date
Thom LambandClaude Opus 4.7 f4d318b35c refactor(dedup): IQueryBreakdownCollectionView eliminates Markdown adapter classes
SonarQube Analysis / sonarqube (pull_request) Successful in 3m39s
Replaces the per-dialect <c>Adapter</c> nested classes (which were
themselves the leftover duplication after PR #22's first cut) with a
shared <c>IQueryBreakdownCollectionView</c> interface implemented
directly on each dialect's <c>QueryBreakdownCollection</c>.

New foundation types in <c>Strata.SqlTools.Breakdowns.SqlServer</c>:

- **<c>IQueryBreakdownCollectionView</c>** — dialect-neutral view
  exposing QueryCount, UniqueParameterCount, TotalSelectedColumns,
  UniqueTableCount, QueriesForReport (typed against the SqlServer
  <c>QueryBreakdown</c> base — PG/Snowflake satisfy via <c>IReadOnlyList</c>
  covariance), and ParameterUsageRecords.
- **<c>ParameterUsageRecord</c>** — record type for per-parameter usage
  stats, projected from each dialect's <c>ParameterUsageReport</c>.

The three dialect <c>QueryBreakdownCollection</c> classes now implement
the interface explicitly — a handful of one-line forwarders per class.
The Markdown layer's old <c>ICollectionMarkdownData</c> interface and
the writer-internal <c>ParameterUsageRow</c> type are deleted; the
template and writer take <c>IQueryBreakdownCollectionView</c> and
<c>ParameterUsageRecord</c> directly.

Net effect on the Markdown wrappers:
- <c>Markdown.SqlServer.QueryBreakdownCollectionGenerator</c> loses
  its <c>Adapter</c> nested class and its 6 forwarders pass <c>collection</c>
  straight through.
- <c>Markdown.PostgreSql.QueryBreakdownCollectionGenerator</c> ditto.
- <c>Markdown.Snowflake.QueryBreakdownCollectionGenerator</c> migrated
  to the same pattern; its dialect-specific
  <c>GenerateSnowflakeFeaturesAnalysis</c> and feature-aware
  <c>QueryCompositionReport</c> callback stay intact (they still call
  <c>CollectionReportWriter</c> directly).

Public API additions: <c>IQueryBreakdownCollectionView</c> and
<c>ParameterUsageRecord</c> (both new, both opt-in). Public API
removals: none — the dialect <c>ParameterUsageReport</c> classes are
untouched and the dialect <c>QueryBreakdownCollectionGenerator</c>
public surface is identical.

All 1180 tests stay green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 17:47:12 -05:00