Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

Summary

  • Renames the Formatter interface to Dialect for better semantic clarity
  • Refactors all AST node Format methods to accept dialect as a parameter instead of storing it in TrackedBuffer
  • Simplifies TrackedBuffer to be a pure buffer utility without dialect dependency

Key Changes

Interface Rename:

  • format.Formatterformat.Dialect

Format Method Signature:

  • Before: Format(buf *TrackedBuffer)
  • After: Format(buf *TrackedBuffer, d format.Dialect)

TrackedBuffer Simplification:

  • Removed formatter field - TrackedBuffer is now just a strings.Builder wrapper
  • NewTrackedBuffer() no longer takes a dialect parameter

Method Call Updates:

  • buf.astFormat(x)buf.astFormat(x, d)
  • buf.join(x, sep)buf.join(x, d, sep)
  • Dialect methods called directly: d.QuoteIdent(), d.TypeName(), d.Param(), d.Cast(), d.NamedParam()

Rationale

The name "Dialect" better describes what this interface represents - SQL dialect-specific formatting behavior. Making the dialect an explicit parameter to Format methods:

  1. Makes the dependency explicit and traceable
  2. Simplifies TrackedBuffer to be a pure utility class
  3. Aligns with common patterns for dialect-aware SQL formatting

Test plan

  • All TestFormat tests pass
  • All TestReplay tests pass
  • All go test ./... tests pass
  • No regressions in PostgreSQL, MySQL, or SQLite formatting

🤖 Generated with Claude Code

Renames the Formatter interface to Dialect and refactors Format methods
to accept the dialect as a parameter instead of storing it in TrackedBuffer.

**Interface Changes:**
- Rename `format.Formatter` to `format.Dialect`
- Change Format signature from `Format(buf *TrackedBuffer)` to
  `Format(buf *TrackedBuffer, d format.Dialect)`

**TrackedBuffer Simplification:**
- Remove `formatter` field from TrackedBuffer struct
- TrackedBuffer is now a simple strings.Builder wrapper
- NewTrackedBuffer() no longer takes a dialect parameter

**Method Call Updates:**
- `buf.astFormat(x)` → `buf.astFormat(x, d)`
- `buf.join(x, sep)` → `buf.join(x, d, sep)`
- Helper methods now called directly on dialect:
  - `buf.QuoteIdent(x)` → `d.QuoteIdent(x)`
  - `buf.TypeName(ns, name)` → `d.TypeName(ns, name)`
  - `buf.Param(n)` → `d.Param(n)`
  - `buf.Cast(arg, t)` → `d.Cast(arg, t)`
  - `buf.NamedParam(name)` → `d.NamedParam(name)`

This change makes the dialect dependency explicit in Format methods
and simplifies TrackedBuffer to be purely a buffer utility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🔧 golang labels Dec 1, 2025
@kyleconroy kyleconroy merged commit ebd32cf into main Dec 1, 2025
13 checks passed
@kyleconroy kyleconroy deleted the kyle/rename-formatter-to-dialect branch December 1, 2025 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files. 🔧 golang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants