Skip to content

Add parameter macro detection (#86)#88

Open
rathboma wants to merge 1 commit intomainfrom
feature/parameter-macros
Open

Add parameter macro detection (#86)#88
rathboma wants to merge 1 commit intomainfrom
feature/parameter-macros

Conversation

@rathboma
Copy link
Contributor

@rathboma rathboma commented Mar 5, 2026

Summary

Implements parameter macro parsing as requested in issue #86.

  • Detects -- %name% = value (inline) and /* %name% = value */ (block) comment declarations before a SQL statement
  • Exposes them as parameterMacros: Record<string, string> on both Statement and IdentifyResult
  • Macros are scoped to the immediately following statement — they do not bleed across statement boundaries
  • Macro value is everything after =, trimmed of whitespace

Example:

-- %id% = 7
SELECT * FROM table WHERE id = %id%;

Returns parameterMacros: { id: '7' } on the SELECT result. Substitution of %id% in the SQL body is left to consumers (e.g. Beekeeper Studio).

Test plan

  • Single inline macro before a statement
  • Multiple inline macros before a statement
  • Block comment macro syntax
  • Macros do not bleed into subsequent statements
  • Empty parameterMacros: {} when no macros declared
  • All 489 existing tests continue to pass

🤖 Generated with Claude Code

Parse `-- %name% = value` and `/* %name% = value */` comment declarations
before a SQL statement and expose them as `parameterMacros` on the result.
Macros are scoped to the immediately following statement and do not bleed
across statement boundaries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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