Skip to content

[FORMATTING] Fails for psql meta-commands like \restrict #935

@fedorkanin

Description

@fedorkanin

Similar to sqlc-dev/sqlc#4065. When formatting a schema generated by pgdump, I receive the following error:

/node_modules/sql-formatter/dist/cjs/lexer/TokenizerEngine.js:42
        return new Error(`Parse error: Unexpected "${text}" at line ${line} column ${col}.\n${this.dialectInfo()}`);
               ^

Error: Parse error: Unexpected "\restrict " at line 1 column 1.
SQL dialect used: "postgresql".

Usage

I use sql-formatter in a Makefile:

SQL_FORMATTER := npx --yes -- sql-formatter@15.7.0

.PHONY: format-sql
format-sql:
	for f in $(SQL_SOURCES); do $(SQL_FORMATTER) --fix $$f; done

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions