From 300be4ed8173a7d671be13bc9523f91ffc5f8895 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Tue, 6 May 2025 00:09:09 -0400 Subject: [PATCH] v2: remove libpg refs & link to playground --- Cargo.toml | 3 --- docs/docs/quick_start.md | 34 +++++++++++++++++++++++----------- docs/docs/troubleshooting.md | 11 ----------- docs/docusaurus.config.js | 5 +++++ flake.nix | 2 -- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e6299ea7..c21f8336 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ glob = "0.3.1" insta = "1.39.0" jsonwebtoken = "8.1.1" lazy_static = "1.5.0" -libpg_query-sys = { git = "https://github.com/chdsbd/libpg_query-sys.git", rev = "ac223c7b197459d657d166449ccf99883f23bbcb" } log = "0.4.25" reqwest = { version = "0.9.18", features = ["default-tls-vendored"]} serde = { version = "1.0.215", features = ["derive"] } @@ -48,8 +47,6 @@ convert_case = "0.7.1" clap = { version = "4.5.8", features = ["derive"] } # local -squawk-parser = { version = "0.0.0", path = "./crates/parser" } -squawk-linter = { version = "0.0.0", path = "./crates/linter" } squawk-github = { version = "0.0.0", path = "./crates/github" } squawk_lexer = { version = "0.0.0", path = "./crates/squawk_lexer" } squawk_parser = { version = "0.0.0", path = "./crates/squawk_parser" } diff --git a/docs/docs/quick_start.md b/docs/docs/quick_start.md index 71616a89..1a65912f 100644 --- a/docs/docs/quick_start.md +++ b/docs/docs/quick_start.md @@ -7,10 +7,6 @@ slug: / ## Install -Note: due to `squawk`'s dependency on -[`libpg_query`](https://github.com/lfittl/libpg_query/issues/44), `squawk` -only supports Linux and macOS - ```shell npm install -g squawk-cli @@ -18,6 +14,8 @@ npm install -g squawk-cli https://github.com/sbdchd/squawk/releases ``` +**NOTE**: You can also try Squawk in the browser via the [Squawk Playground](https://play.squawkhq.com)! + ## Usage
example-migration.sql @@ -40,20 +38,34 @@ squawk example-migration.sql
-```shell +``` ❯ squawk example-migration.sql -example-migration.sql:2:1: warning: disallowed-unique-constraint - - 2 | ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name); - - note: Adding a UNIQUE constraint requires an ACCESS EXCLUSIVE lock which blocks reads. - help: Create an index CONCURRENTLY and create the constraint using the index. +warning[constraint-missing-not-valid]: By default new constraints require a table scan and block writes to the table while that scan occurs. + --> example-migration.sql:2:24 + | +2 | ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +warning[disallowed-unique-constraint]: Adding a `UNIQUE` constraint requires an `ACCESS EXCLUSIVE` lock which blocks reads and writes to the table while the index is built. + --> example-migration.sql:2:28 + | +2 | ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: Create an index CONCURRENTLY and create the constraint using the index. + +Find detailed examples and solutions for each rule at https://squawkhq.com/docs/rules +Found 2 issues in 1 file (checked 1 source file) ``` See ["Running Migrations"](./safe_migrations.md#safety-requirements) for information about safely applying migrations in Postgres. The [CLI docs](./cli.md) have more information about the `squawk` CLI tool and the [GitHub Integration docs](./github_app.md) outline configuring Squawk to work with GitHub pull requests. +## Playground + +You can also lint your SQL in the [Squawk Playground](https://play.squawkhq.com) using the WASM compiled version! + ## GitHub Action ```yml diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 08e8952e..52b381ef 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -4,14 +4,3 @@ title: Troubleshooting --- If you encounter an issue using Squawk that can't be resolved with these docs, please [open an issue](https://github.com/sbdchd/squawk/issues/new). - - -## common error messages - -### postgres failed to parse query - -Squawk was unable to parse the query using the PostgreSQL parser. - -Usually the provided statement contains an error and isn't a valid Postgres statement. - -Squawk uses the [libpg_query-sys](https://github.com/tdbgamer/libpg_query-sys) Rust bindings to [libpg_query](https://github.com/pganalyze/libpg_query) to parse Postgres queries using the Postgres parser. diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 2f13c05f..dcd7dd3f 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -53,6 +53,11 @@ module.exports = { label: "Rules", position: "left", }, + { + href: "https://play.squawkhq.com", + label: "Playground", + position: "right", + }, { to: "docs/", label: "Quick Start", diff --git a/flake.nix b/flake.nix index 4c22eacc..65000a3b 100644 --- a/flake.nix +++ b/flake.nix @@ -39,8 +39,6 @@ Security ]); - LIBPG_QUERY_PATH = final.libpg_query; - meta = with lib; { description = "Linter for PostgreSQL, focused on migrations"; homepage = "https://github.com/sbdchd/squawk";