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

better formatting #515

Closed
xenoterracide opened this issue Feb 25, 2020 · 1 comment
Closed

better formatting #515

xenoterracide opened this issue Feb 25, 2020 · 1 comment

Comments

@xenoterracide
Copy link

xenoterracide commented Feb 25, 2020

Thanks for creating this project, it's pretty awesome.

I've encountered some formatting issues though. So when I formatted, this is my result

--changeset ccushing:0004-money
  create table currency (
    id uuid primary key not null default uuid_generate_v4(),
    code text not null,
    description text,
    notes text,
    created_at timestamp with time zone default now() not null,
    created_by text default ("current_user"()) :: text not null,
    modified_at timestamp with time zone default now() not null,
    modified_by text default ("current_user"()) :: text not null,
    deleted boolean default false not null,
    deleted_at timestamp with time zone,
    deleted_by text
  );
create unique index if not exists public_currency_idx on currency (code)
where
  deleted_at is null;
create unique index if not exists public_currency_deleted_idx on currency (code)
where
  deleted is false;
create trigger t_public_currency before
update on currency for each row execute procedure public.f_update_modified_records();
insert into currency (code)
values
  ('USD');
--changeset ccushing:0004-01-add-payment-methods stripComments:true

what I'd like to get is whitespace between statements and before comments, and column align types.

--changeset ccushing:0004-money
  create table currency (
    id                  uuid primary key not null default uuid_generate_v4(),
    code             text not null,
    description  text,
    notes            text,
    created_at    timestamp with time zone default now() not null,
    created_by   text default ("current_user"()) :: text not null,
    modified_at  timestamp with time zone default now() not null,
    modified_by text default ("current_user"()) :: text not null,
    deleted         boolean default false not null,
    deleted_at    timestamp with time zone,
    deleted_by    text
  );

create unique index if not exists public_currency_idx on currency (code)
where
  deleted_at is null;

create unique index if not exists public_currency_deleted_idx on currency (code)
where
  deleted is false;

create trigger t_public_currency before
update on currency for each row execute procedure public.f_update_modified_records();
insert into currency (code)
values
  ('USD');

--changeset ccushing:0004-01-add-payment-methods stripComments:true

it's worth noting before I formatted that this whitespace was in place.

it would also be nice to have the option to uppercase sql keywords

@xenoterracide xenoterracide added the feature request New issue opened using "Feature request" template label Feb 25, 2020
@mtxr mtxr added enhancement formatting and removed feature request New issue opened using "Feature request" template labels May 11, 2020
@mtxr
Copy link
Owner

mtxr commented May 12, 2020

Hey @xenoterracide!

The option to uppercase words already exists.
Try this:

"sqltools.format": {
  "reservedWordCase": "upper"
},

the column alignment for types you can achieve using other extensions that you can find in the market place.

https://marketplace.visualstudio.com/items?itemName=matthewthorning.align-vertically
https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.align-mode

I don't plan to add it here now because the extension is growing a lot and there are a lot of changes between v0.21 -> v0.22 already. So since we have an alternative for this, I'll close the issue.

@mtxr mtxr closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants