sprocguard

v0.3.1
io.github.JheysonJhordyHuarauyaRiquelme/sprocguard Checked 3 days ago Published 5 days ago

Safety net for SQL Server stored procedures: capture their behavior and verify changes.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

inspect_procedure

Describe a stored procedure: parameters, tables it reads and writes, procedures and triggers involved, and risks (external side effects, dynamic SQL, nondeterminism). Call this first. `procedure` is a name like 'dbo.usp_PlaceOrder'.

ParameterTypeDescription
procedure *string
include_definitionboolean

suggest_cases

Suggest parameter values for test cases: real values found in related tables plus edge values (0, -1, empty, NULL). Use them to design cases that cover every branch.

ParameterTypeDescription
procedure *string

capture_baseline

Record what the procedure does TODAY, before you change it. `cases` is a list like [{"name": "customer with orders", "params": {"@CustomerId": 1}}]. Each case runs twice inside a rolled-back transaction; result sets, return value, OUTPUT parameters, errors and table changes are saved to a baseline file. Values that change by themselves (dates, new IDs) are detected and ignored later. `watch_tables` adds tables to compare (useful with dynamic SQL). Refuses to replace an existing baseline unless overwrite=true.

ParameterTypeDescription
cases *array
procedure *string
overwriteboolean
watch_tables

verify_procedure

Re-run the baseline cases against the procedure as it is now in the database and list every difference in behavior. Run it after deploying your change to the development database. An empty difference list for every case means the behavior is unchanged.

ParameterTypeDescription
procedure *string

generate_tsqlt_tests

Turn the baseline into tSQLt tests (a .sql file) so the safety net can run in CI. Version 0.1 supports read-only procedures.

ParameterTypeDescription
procedure *string

list_baselines

List the procedures that already have a baseline.