vertical-align may stop working with certain CHECK constraint expressions
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Reproduce the problem with the supplied SQL on pgFormatter 5.11, comparing the CHECK constraint table with the following table. Trace the vertical-align formatting behavior around CHECK expressions; done when both tables and subsequent statements receive vertical alignment consistently, with coverage for the reported example.
Written by the indexing model from the issue text.
Description
Thank you for developing and maintaining such a useful tool.
The long-awaited vertical-align feature was added in the latest version: #398
However, although I have not been able to determine the exact conditions that trigger the issue, it seems that certain CHECK constraint expressions can cause vertical alignment not to be applied.
For example, with the following SQL, vertical alignment is not applied to sample_with_check. Once this happens, vertical alignment is also not applied to the SQL statements that follow it, such as sample_after_check.
This does not seem to occur with every CHECK constraint, so the issue may depend on the contents or structure of the constraint expression.
I am using pgFormatter version 5.11 on macOS.
CREATE TABLE sample_with_check
(
id VARCHAR(36) NOT NULL,
code SMALLINT NOT NULL,
description VARCHAR(255),
CONSTRAINT ck_code_description
CHECK (code <> 4 OR (description IS NOT NULL AND description <> ''))
);
CREATE TABLE sample_after_check
(
id SERIAL NOT NULL,
description TEXT NOT NULL,
PRIMARY KEY (id)
);
- Dominant language
- PLpgSQL
- Stars
- 2k
- Forks
- 124
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from darold/pgFormatter
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
darold/pgFormatter#426 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
darold/pgFormatter#391 · 1 comment ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 45/100
darold/pgFormatter#351 · 5 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
darold/pgFormatter#347 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
darold/pgFormatter#333 · 4 comments · 1 reaction ·
All issues in darold/pgFormatter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
microsoft/agent-framework#9946 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 62/100
rmax/scrapy-redis#337 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Index conflicts report and internal errorPossibly taken A pull request linked to this issue is open or already merged. Opentriage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
chriskelly/wish-together#102 ·
Maintainers usually reply within 1 day