Skip to content

Releases: stevehansen/sql-inliner

2.4.1

02 Mar 08:51
1b8a1e5

Choose a tag to compare

New Features

  • DerivedTableStripper — New post-processing step that recursively strips unused columns and LEFT OUTER JOINs inside nested derived tables produced by inlining. Runs after inlining when --strip-unused-columns or --strip-unused-joins is enabled. Iterates until no more stripping occurs to handle cascading effects across nesting levels.

  • validate command — Batch-validates all views in a database. Phase 1 inlines every view and reports errors; Phase 2 (with --deploy) deploys and runs COUNT + EXCEPT comparisons. Supports --deploy-only for fast SQL error checking, --filter (exact or SQL LIKE % wildcard), --output-dir, --stop-on-error, and --timeout.

  • verify command — Auto-detects already-deployed inlined views (identified by BeginOriginal/EndOriginal markers) and validates them against their originals using COUNT + EXCEPT comparisons. Supports --filter, --stop-on-error, and --timeout.

  • Two-phase analyze — New --generate-script flag emits a self-contained SQL Server stored procedure for offline data extraction. The exported JSON can then be analyzed without a live database connection using --from-file. Useful for environments with restricted direct database access.

  • Cross-platform credential store — Store connection string credentials securely per-platform: Windows Credential Manager, macOS Keychain, and Linux secret-tool (libsecret). Managed via the credentials subcommand (add, list, remove).

Bug Fixes

  • Fix SelectStarExpression handlingSELECT * and SELECT alias.* were not recognized as column references during column stripping and schema normalization, causing incorrect stripping of inner view columns.

  • Fix flattener/stripper/inliner bugs — Resolved a set of cascading issues that caused validation errors on complex view chains. Reduced validate errors from 36 to 0 on a 486-view database.

  • Fix validate timeout/row count messaging — COUNT on the inlined view now runs first so row counts appear in timeout messages; summary details show correct inlined row counts.

Security

  • Parameterized queriesDatabaseConnection now uses parameterized queries via Dapper to prevent SQL injection when querying sys.views. Previously, view names were interpolated directly into query strings.

Patch (2.4.0 → 2.4.1)

  • Fix net472/netstandard2.0 buildDerivedTableFlattener used Dictionary.GetValueOrDefault() and KeyValuePair tuple deconstruction, both of which are unavailable in net472 and netstandard2.0. The NuGet library package failed to build in 2.4.0; 2.4.1 fixes both. The CLI (net8.0) was unaffected.

2.3.0

26 Feb 10:51
50a4acf

Choose a tag to compare

Bug fix

  • Fix column alias loss during derived table flattening — When a view was flattened inside a GROUP BY query, column references like v.CompanyId were rewritten to their inner expression (e.g., Companies_1.Id), silently changing the inferred column name from CompanyId to Id. Outer queries referencing the original name (e.g., cl.CompanyId) would then fail with "Invalid column name". The fix snapshots inferred SELECT column names before rewriting and restores them as explicit AS aliases when the last identifier changes.

2.2.0

26 Feb 05:51
00bd32e

Choose a tag to compare

What's New

Features

  • Derived table flattening — New FlattenDerivedTables option that removes unnecessary subquery wrappers after inlining
    • Phase 1: Single-table inner queries
    • Phase 2: Multi-table (JOIN) inner queries
    • Preserves derived table aliases on flattened single-table queries
  • JSON config file — New sqlinliner.json config file support with --config option
  • Join stripping for derived tables — Extended join stripping to handle inline subqueries
  • Persisted options — InlinerOptions stored in metadata comment and restored in optimize wizard
  • Benchmark improvements — HTML benchmark report, per-table IO breakdown, execution plan capture

Bug Fixes

  • Fix benchmark returning 0ms by flushing TDS messages and forcing English locale
  • Add warmup run before benchmark for fair cache comparison
  • Traverse UnqualifiedJoin (CROSS/OUTER APPLY) subtrees in flattener
  • Merge inner WHERE into JOIN ON clause instead of outer WHERE
  • Rewrite GROUP BY/HAVING refs and qualify unqualified columns in flattener
  • Resolve nullable compiler warnings in DatabaseConnection
  • Apply config file options as defaults in the optimize wizard
  • Wire FlattenDerivedTables into the optimize wizard
  • Fix no-args crash

2.1.0

25 Feb 09:42
14f0d28

Choose a tag to compare

New feature: Interactive optimization wizard

The new sqlinliner optimize subcommand provides a guided, interactive workflow for optimizing a view against a backup or development database. It walks you through the full troubleshooting cycle in one session:

  1. Connect to a backup DB (with prominent safety warning)
  2. Select a view and see metadata (SQL length, nested view count)
  3. Inline the view with the current options
  4. Review the generated SQL in your default editor (detects manual edits)
  5. Deploy as [schema].[ViewName_Inlined] via CREATE OR ALTER VIEW
  6. Validate correctness with COUNT and EXCEPT comparisons
  7. Iterate — toggle strip-joins / aggressive mode and re-inline
  8. Benchmark — compare CPU time, elapsed time, and logical reads (SET STATISTICS TIME/IO)
  9. Summary — session directory with all iterations, recommended SQL, and a printed (never executed) DROP VIEW cleanup statement
sqlinliner optimize \
  -cs "Server=.;Database=TestBackup;Integrated Security=true" \
  -vn "dbo.VHeavy"

New features

  • Auto-strip outer joins whose columns are only referenced in their own ON clause — LEFT/RIGHT/FULL OUTER JOINs are now automatically stripped when the joined table contributes no columns outside its join condition (no need for --aggressive-join-stripping).
  • @join:unique and @join:required hints — annotate JOINs in your SQL to enable safe join removal for LEFT JOIN (with @join:unique) and INNER JOIN (with @join:unique @join:required).

Other changes

  • Overhauled README and CLI --help with comprehensive feature documentation
  • Updated Microsoft.NET.Test.Sdk to 18.3.0

2.0.3

24 Feb 16:10
71ae04c

Choose a tag to compare

Fix

  • Aggressive join stripping (stripping joins where the table is only referenced in its own ON clause) is now opt-in via --aggressive-join-stripping. The previous default could incorrectly strip INNER JOINs with filter conditions in the ON clause, producing more rows than expected.

New option

  • --aggressive-join-stripping CLI flag / AggressiveJoinStripping on InlinerOptions — enables the more aggressive join-condition exclusion logic. Use with caution as it can change results for INNER JOINs.

2.0.2

24 Feb 15:35
774a404

Choose a tag to compare

Fix

  • Restore implicit alias assignment for views in subquery scopes. Views referenced multiple times across different subqueries (e.g. in OUTER APPLY) no longer fail with "Use of tables without using an alias" errors.

Tests

  • Add regression test for same view in multiple subquery scopes
  • Add join stripping tests for both implicit and explicit alias cases

2.0.1

24 Feb 14:56
2d77731

Choose a tag to compare

Fix

  • Publish both dotnet tool (SqlInliner) and library (SqlInliner.Library) NuGet packages. The library package was incorrectly marked as a DotnetTool, preventing it from being referenced by projects.

2.0.0

24 Feb 14:36
18ba4c3

Choose a tag to compare

What's new

Features

  • Package as dotnet tool (dotnet tool install -g SqlInliner)
  • Add file output and logging options
  • Convert tests to use Shouldly and improve view inlining logic

Bug fixes

  • Strip unused joins with multiple ON conditions (e.g. INNER JOIN b ON a.BId = b.Id AND b.Type = 'B' now correctly strips when b is unused elsewhere)
  • Update Program.cs for System.CommandLine 2.0.3 stable API

Infrastructure

  • Switch NuGet publishing to OIDC trusted publishing
  • Add osx-arm64 build target
  • Drop EOL framework targets (netcoreapp3.1, net6.0), add net9.0 and net10.0
  • Updated dependencies (DacFx, Dapper, MinVer, ThisAssembly, and more)
  • Added 62+ unit tests covering core functionality

v1.0.0

18 Oct 19:47
d9b80d4

Choose a tag to compare

Updated packages and switched to .NET 6.0

0.4.0-alpha

16 May 19:17

Choose a tag to compare

Added target frameworks net472 and netcoreapp3.1

- Added missing comments
- Fixed compile error on netstandard2.0