Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite format doesn't always split on comma #65

Open
reedy opened this issue Aug 2, 2020 · 1 comment
Open

SQLite format doesn't always split on comma #65

reedy opened this issue Aug 2, 2020 · 1 comment

Comments

@reedy
Copy link
Contributor

reedy commented Aug 2, 2020

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
);
@mvorisek
Copy link
Contributor

mvorisek commented May 13, 2024

I belive the splitting is done on line length, thus this is not related to SQLite. But I tend to agree, splitting should be done for all lines if it does not fit on a single line.

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

No branches or pull requests

2 participants