Skip to content

Add sql<number> aggregate type assertion check#40

Merged
rwdaigle merged 2 commits into
mainfrom
ryan/sql-inventory-docs
Feb 26, 2026
Merged

Add sql<number> aggregate type assertion check#40
rwdaigle merged 2 commits into
mainfrom
ryan/sql-inventory-docs

Conversation

@rwdaigle

@rwdaigle rwdaigle commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a new Drizzle check that detects sql<number> tagged templates containing SQL aggregate functions (SUM, AVG, COUNT, MIN, MAX)
  • These queries always return strings from the database driver, so the <number> generic is a false assertion that creates silent runtime type mismatches
  • Bumps version to 0.10.0

Details

  • Check: Detects pattern where sql<T> generic contains number AND SQL body contains aggregate keywords
  • Severity: Error (sql assertion is always violated at runtime)
  • Category: drizzle (part of persistence check)
  • Implementation: 115 lines in persistence-check.ts, independent AST walk for sql tagged templates
  • Test Coverage: 7 new tests, 1 fixture file with 5 bad + 4 safe patterns, all 213 tests passing

Verified

  • All checks run and pass without regression
  • Deterministic pattern matching (syntactic only, no runtime inference needed)
  • Works with PostgreSQL, MySQL, and other databases that return aggregates as strings
  • Documentation updated across README.md, SKILL.md, and CLAUDE.md

rwdaigle and others added 2 commits February 26, 2026 10:02
Detects sql<number> tagged templates containing aggregate functions (SUM, AVG, COUNT, MIN, MAX). Databases return these as strings, creating silent runtime type mismatches. Severity: error, category: drizzle.

Includes test fixture with 5 bad patterns and 4 safe patterns, comprehensive test coverage with 7 new tests, all 213 tests passing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rwdaigle rwdaigle merged commit 01d98ec into main Feb 26, 2026
2 checks passed
@rwdaigle rwdaigle deleted the ryan/sql-inventory-docs branch February 26, 2026 15:07

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

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.

1 participant