Unibeautify / beautifier-sqlformat

sqlformat for Unibeautify
Other
3 stars 1 forks source link

Add Option: Closing Bracket Position #62

Open calvindio opened 4 years ago

calvindio commented 4 years ago

Option Details Name: Closing Bracket Position

If this is a new option, please fill out the below Type (boolean, multi-select, number, etc): multi-select Values (if applicable):

If this is to update an existing option, please describe what should be updated

Additional context From what I think, there are 3 logical possible places to put the closing bracket

1. Common (after the last line of the block, at the same indentation level as the block's opening)

create table A (
    id serial primary key,
    title varchar(50) not null
);
create table B (
    id serial primary key,
    title varchar(50) not null
);
create table C (
    id serial primary key,
    title varchar(50) not null
);
const A = {
    name: "John Doe",
    age: 30
};
const B = {
    name: "John Doe",
    age: 30
};
const C = {
    name: "John Doe",
    age: 30
};

pros

cons

2. Condensed (at the end of the last line of the block)

create table A (
    id serial primary key,
    title varchar(50) not null);
create table B (
    id serial primary key,
    title varchar(50) not null);
create table C (
    id serial primary key,
    title varchar(50) not null);
const A = {
    name: "John Doe",
    age: 30};
const B = {
    name: "John Doe",
    age: 30};
const C = {
    name: "John Doe",
    age: 30};

pros

cons

cons

Right now, I have to turn off autoformatting for sql file (postgresql) because I find it easier to identify create table blocks and understand a complicated select statement with hybrid style bracket. I still use autoformatting for js, ts, etc. because I find the convenience of autoformatting outweigh the cost of > structure of the blocks.

Glavin001 commented 4 years ago

Unibeautify currently supports sqlformat beautifier for SQL language: https://unibeautify.com/docs/language-sql

List of supported options in sqlformat's document is found at https://sqlparse.readthedocs.io/en/latest/api/#formatting-of-sql-statements

I do not see a supported option which would satisfy your description. I recommend you request this option in https://github.com/andialbrecht/sqlparse/issues . If sqlformat adds a new option we can add to Unibeautify's sqlformat beautifier here: https://github.com/Unibeautify/beautifier-sqlformat/blob/master/src/options.ts Thanks!

Glavin001 commented 4 years ago

Transfered this issue to applicable sqlformat beautifier's repository. If another beautifier supports this option for SQL we could add it, too.

calvindio commented 4 years ago

For Javascript, the request should be added to eslint?