phpmyadmin / phpmyadmin/sql-parser
Formatter doesn't handle CASE expressions and statements
Open
Nobody has claimed this yet.
bug
- Dominant language
- PHP
- Stars
- 485
- Forks
- 119
- PR merge metrics
- No merged PRs in 30d
Description
Formatter doesn't handle CASE expressions and CASE statements.
Related to #272.
Examples:
CASE expression:
-- original
SELECT CASE 1
WHEN 1 THEN
'one'
WHEN 2 THEN
'two'
ELSE
'more'
END;
-- formatted
SELECT CASE
1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'more'
END;
CASE statement:
-- original
CREATE PROCEDURE p()
BEGIN
DECLARE
v INT DEFAULT 1;
CASE v
WHEN 2 THEN
SELECT v;
WHEN 3 THEN
SELECT 0;
ELSE
BEGIN
END;
END CASE;
END;
-- formatted
CREATE PROCEDURE p()
BEGIN
DECLARE
v INT DEFAULT 1; CASE v WHEN 2 THEN
SELECT
v; WHEN 3 THEN
SELECT
0; ELSE
BEGIN
END
;
END CASE;
END;
Contributor 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.
Research direction
Use the MySQL CASE expression and CASE statement references, plus the two formatting examples, as the acceptance cases. Compare the current formatter behavior with related issue #272, then locate the formatter entry point and add coverage for both forms; done means each example retains readable CASE and statement clause indentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100