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

Formatter should respect indentation #819

Open
ngdangtu-vn opened this issue May 17, 2021 · 1 comment
Open

Formatter should respect indentation #819

ngdangtu-vn opened this issue May 17, 2021 · 1 comment
Labels
feature request New issue opened using "Feature request" template formatting

Comments

@ngdangtu-vn
Copy link

Is your feature request related to a problem? Please describe.
The way Formatter killed off all my indentation cause me a lot of trouble in reading the code. Please don't do that.

-- Origin
CREATE TABLE contact_groups(
	contact_id INTEGER,
	group_id INTEGER,
	PRIMARY KEY (contact_id, group_id),
	FOREIGN KEY (contact_id)
		REFERENCES contacts (contact_id)
			ON DELETE CASCADE
			ON UPDATE NO ACTION,
	FOREIGN KEY (group_id)
		REFERENCES groups (group_id)
			ON DELETE CASCADE
			ON UPDATE NO ACTION
);
-- Formatted
CREATE TABLE contact_groups(
	contact_id INTEGER,
	group_id INTEGER,
	PRIMARY KEY (contact_id, group_id),
	FOREIGN KEY (contact_id) REFERENCES contacts (contact_id) ON DELETE CASCADE ON UPDATE NO ACTION,
	FOREIGN KEY (group_id) REFERENCES groups (group_id) ON DELETE CASCADE ON UPDATE NO ACTION
);

Describe the solution you'd like
I simply want the formatter respect my indentation. Therefore I would like to add this option:

{
	"sqltools.format": {
		"language": "sql",
		"reservedWordCase": "upper",
		"linesBetweenQueries": 3,
		"indentation": "preserve | nested | crowed"
	}
}

Where as:

  • preserve means nothing changes (default)
  • nested detects certain keywords and send them to a newline. For instance, ON and REFERENCES require a new indented line. (my format above)
  • crowed packs everything in one line (the current format)
@ngdangtu-vn ngdangtu-vn added the feature request New issue opened using "Feature request" template label May 17, 2021
@BenGinders
Copy link

This would be great if it could be added, currently indentation type or amount is not valid in the sqltools.format setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New issue opened using "Feature request" template formatting
Projects
None yet
Development

No branches or pull requests

3 participants