Skip to content

Formatting issue for DO $$ block #183

Closed
@egel

Description

@egel

Hey, thanks for your attention upfront.

I recently wanted to try your formatter, which seems btw working very great and stable.
Unfortunately, I stumble upon a problem that my SQL code has been formatted in a way that stopped working while executing while doing migrations. Hope this might help you better structure your formatter. & keep being awesome :)

Code that works fine:

DO $$
  BEGIN IF NOT EXISTS (
    SELECT
      1
    FROM
      pg_type
    WHERE
      typname = 'translations_statuses'
  ) THEN CREATE TYPE translations_statuses AS ENUM (
    'todo',
    'in_progress',
    'to_verify',
    'to_accept',
    'rejected',
    'accepted'
  );
  END IF;
END $$;

Code after formatting which does not work:

DO $ $ BEGIN IF NOT EXISTS (
  SELECT
    1
  FROM
    pg_type
  WHERE
    typname = 'translations_statuses'
) THEN CREATE TYPE translations_statuses AS ENUM (
  'todo',
  'in_progress',
  'to_verify',
  'to_accept',
  'rejected',
  'accepted'
);

END IF;

END $ $;

sql-formatter version: v4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions