Skip to content

current_timestamp -> current_timestamp() breaking postgres #50

Open
@wathiede

Description

Example

CREATE TABLE t (
  created_at TIMESTAMP DEFAULT current_timestamp NOT NULL
);

generates

CREATE TABLE t (
	created_at TIMESTAMP
	           DEFAULT current_timestamp()
	           NOT NULL
);

Note the () after current_timestamp, this is invalid syntax for postgres. I'm guessing you're normalizing to the built in function names as documented on https://www.cockroachlabs.com/docs/stable/functions-and-operators.html#special-syntax-forms

I know you're focused on cockroach syntax, but this formatting nit keeps your otherwise super useful utility from being useful for postgres too.

Have you considered a dialect option, or something else that would allow sqlfmt to work for non-cockroach dialects? I understand the maintenance burden on you that sort of option could entail, but this tool is the best sql formatter I've come across, so I thought I'd ask.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions