Skip to content

P2: Formatter — add render handlers for Sequence DDL and SHOW/DESCRIBE statements #455

@ajitpratap0

Description

@ajitpratap0

Problem

The formatter (pkg/formatter/render.go) is missing render handlers for several statement types, which causes round-trip failures: you can parse these statements but cannot format them back to SQL.

Missing Handlers

Statement Type Dialect Impact
CreateSequenceStatement PostgreSQL, Oracle, MariaDB (v1.14.0) Cannot format sequence DDL
AlterSequenceStatement PostgreSQL, Oracle, MariaDB Cannot format sequence modifications
DropSequenceStatement PostgreSQL, Oracle, MariaDB Cannot format sequence drops
ShowStatement MySQL, MariaDB, ClickHouse Cannot format SHOW DATABASES/TABLES/CREATE
DescribeStatement MySQL, MariaDB, PostgreSQL (\d) Cannot format DESCRIBE/\d table

Impact

Parse → transform → format workflows fail silently (returns empty string or error) for:

CREATE SEQUENCE order_id START 1 INCREMENT 1 MINVALUE 1 MAXVALUE 9999999 CACHE 10;
ALTER SEQUENCE order_id RESTART WITH 100;
DROP SEQUENCE IF EXISTS order_id;
SHOW TABLES LIKE 'user%';
DESCRIBE users;

Implementation

Add to pkg/formatter/render.go:

case *ast.CreateSequenceStatement:
    return r.renderCreateSequence(stmt)

case *ast.AlterSequenceStatement:
    return r.renderAlterSequence(stmt)

case *ast.DropSequenceStatement:
    return r.renderDropSequence(stmt)

case *ast.ShowStatement:
    return r.renderShow(stmt)

case *ast.DescribeStatement:
    return r.renderDescribe(stmt)

Acceptance Criteria

  • CreateSequenceStatement renders correctly (all options: START, INCREMENT, MINVALUE, MAXVALUE, CACHE, CYCLE/NO CYCLE)
  • AlterSequenceStatement renders correctly
  • DropSequenceStatement renders correctly (with IF EXISTS)
  • ShowStatement renders correctly for all variants (SHOW TABLES, SHOW DATABASES, SHOW CREATE TABLE, SHOW PROCESSLIST)
  • DescribeStatement renders correctly
  • Round-trip test: parse → format → parse → compare ASTs (identity)
  • Keyword casing respects formatter options
  • Tests for all new handlers: 5+ per statement type

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priorityenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions