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

Wrong formatted PostgreSQL #9

Open
ansidev opened this issue May 8, 2023 · 2 comments
Open

Wrong formatted PostgreSQL #9

ansidev opened this issue May 8, 2023 · 2 comments

Comments

@ansidev
Copy link

ansidev commented May 8, 2023

Input:

CREATE EXTENSION IF NOT EXISTS pgcrypto;

CREATE OR REPLACE FUNCTION generate_ulid() RETURNS uuid
    AS $$
        SELECT (lpad(to_hex(floor(extract(epoch FROM clock_timestamp()) * 1000)::bigint), 12, '0') || encode(gen_random_bytes(10), 'hex'))::uuid;
    $$ LANGUAGE SQL;

Output:

CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE
OR REPLACE FUNCTION generate_ulid() RETURNS uuid AS $ $
SELECT
  (
    lpad(
      to_hex(
        floor(
          extract(
            epoch
            FROM
              clock_timestamp()
          ) * 1000
        ) :: bigint
      ),
      12,
      '0'
    ) || encode(gen_random_bytes(10), 'hex')
  ) :: uuid;
$ $ LANGUAGE SQL;
@nrempel
Copy link
Owner

nrempel commented May 9, 2023

Thanks for the report! Right now this CLI is a front end for https://github.com/shssoichiro/sqlformat-rs. Can you open an issue there?

@ansidev
Copy link
Author

ansidev commented May 9, 2023

@nrempel shssoichiro/sqlformat-rs#20

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