Skip to content

SQLite format doesn't always split on comma #65

@reedy

Description

@reedy

In this example, why doesn't ct_tag_id end up on a new row?

Given

CREATE TABLE /*_*/change_tag (ct_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ct_rc_id INTEGER UNSIGNED DEFAULT NULL, ct_log_id INTEGER UNSIGNED DEFAULT NULL, ct_rev_id INTEGER U>

CREATE UNIQUE INDEX change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id, ct_tag_id);

CREATE UNIQUE INDEX change_tag_log_tag_id ON /*_*/change_tag (ct_log_id, ct_tag_id);

CREATE UNIQUE INDEX change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id, ct_tag_id);

After running ( new SqlFormatter( new NullHighlighter() ) )->format( $sql ) we end up with

CREATE TABLE
/*_*/
change_tag (
  ct_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  ct_rc_id INTEGER UNSIGNED DEFAULT NULL,
  ct_log_id INTEGER UNSIGNED DEFAULT NULL,
  ct_rev_id INTEGER UNSIGNED DEFAULT NULL,
  ct_params BLOB DEFAULT NULL, ct_tag_id INTEGER UNSIGNED NOT NULL
); CREATE UNIQUE INDEX change_tag_rc_tag_id ON
/*_*/
change_tag (ct_rc_id, ct_tag_id); CREATE UNIQUE INDEX change_tag_log_tag_id ON
/*_*/
change_tag (ct_log_id, ct_tag_id); CREATE UNIQUE INDEX change_tag_rev_tag_id ON
/*_*/
change_tag (ct_rev_id, ct_tag_id); CREATE INDEX change_tag_tag_id_id ON
/*_*/
change_tag (
  ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id
);

We should end up with (ignoring #53)

CREATE TABLE
/*_*/
change_tag (
  ct_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  ct_rc_id INTEGER UNSIGNED DEFAULT NULL,
  ct_log_id INTEGER UNSIGNED DEFAULT NULL,
  ct_rev_id INTEGER UNSIGNED DEFAULT NULL,
  ct_params BLOB DEFAULT NULL,
  ct_tag_id INTEGER UNSIGNED NOT NULL
); CREATE UNIQUE INDEX change_tag_rc_tag_id ON
/*_*/
change_tag (ct_rc_id, ct_tag_id); CREATE UNIQUE INDEX change_tag_log_tag_id ON
/*_*/
change_tag (ct_log_id, ct_tag_id); CREATE UNIQUE INDEX change_tag_rev_tag_id ON
/*_*/
change_tag (ct_rev_id, ct_tag_id); CREATE INDEX change_tag_tag_id_id ON
/*_*/
change_tag (
  ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions