sbdchd / squawk

🐘 linter for PostgreSQL, focused on migrations
https://squawkhq.com
GNU General Public License v3.0
599 stars 40 forks source link

Cannot parse SQL queries using functions #55

Closed oomathias closed 4 years ago

oomathias commented 4 years ago

Hi, thanks for creating this tool.

I have a few migrations that cannot be parsed when using functions.

ALTER TABLE foobar ALTER COLUMN value SET DEFAULT TO_JSON(false);
Err(
    CheckSQL(
        ParsingSQL(
            JsonParse(
                "unknown variant `FuncCall`, expected one of `Constraint`, `ColumnDef`, `A_Const`, `ReplicaIdentityStmt` at line 1 column 220",
            ),
        ),
    ),
)

Do you plan to support those?

sbdchd commented 4 years ago

Yeah shouldn't be too hard.

Currently squawk parses the json from https://github.com/lfittl/libpg_query into structures to make writing the lints less painful. Seems I missed some cases.

oomathias commented 4 years ago

Thanks for being super reactive.

sbdchd commented 4 years ago

I need to futz with the releases a bit before it's available via curl or npm, thanks for the report

sbdchd commented 4 years ago

I've released the new version to npm and the binaries are also available attached to the GitHub release