Repository navigation
Conversation
… plpgsql leftovers Warn on statements before the first section marker and on lines that look like markers but that dbmate or goose read as comments. Don't panic on a plpgsql_check query position that isn't a number, and stop computing the SQL function signature that the database checks ignore. The rules index marks rules with a fix, and the linting docs use a fix that the default config reaches.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #899.
A few section marker mistakes went unreported, and some leftovers from #862/#863 remained. With section markers configured, both of these passed without a diagnostic:
What changed
A new
migrations/sectionMarkersdiagnostic (warning) for:-- Migrate:Upor an indented-- migrate:up, and goose's-- +Goose Down. The tools read these as plain comments, so the file silently has fewer sections. goose matches the annotation itself case-insensitively, but not+goose. An indented-- +gooseannotation is different: goose rejects it, and the message says so.Both are reported only when
sectionMarkersis set. The statement ranges come from aDocument::statement_rangesaccessor, the same one fix(workspace): put the suppression comment above the statement #910 adds, so whichever merges second has an identical hunk. A marker inside a dollar-quoted body is still not reported: dbmate splits there too, so our sections match what the tool runs.plpgsql_check: a query position that isn't a number no longer panics (
expectonparse). The diagnostic falls back to the statement's span like other unlocatable issues.TypecheckDiagnosticsMapperno longer computes the SQL function signature, which fix(workspace): do not typecheck SQL function bodies with EXPLAIN #863 left in place unused.Docs (F15): the rules index marks rules with a fix with 🔧. The linting docs' example of a safe fix now uses
requireConcurrentReindex, which is in the recommended preset, instead ofCREATE INDEX, which needs a rule that isn't. They also say how to enable the other fixable rules and that 🛠 rules only run inmigrationsDir. The migrations guide mentions the new diagnostics.Tests
Unit tests for the new diagnostics: a statement before the first marker for dbmate and goose, wrong-case and indented dbmate markers, goose
+Goose, and no diagnostics without markers. A workspace test checks that they're reported throughpull_file_diagnostics. A plpgsql_check unit test covers a non-numeric query position. The mapper tests are updated.Not covered
ENVSUB(F19).''still can't be located (F20). That needs a different way to find the body in the source thanfind.Follow-ups: goose
ENVSUBis handled by #949. Single-quoted bodies with''are located by scanner token in #918 and #941 (on the #888 stack).