sql-formatter-org / sql-formatter-org/sql-formatter
Feature Request: Format `jsonb_build_object` as `key, value`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 456
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 3
Description
Describe the Feature
When writing JSONB, the standard formatting looks like this…
For me it is a lot easier to read when the key and values share line, like
jsonb_build_object('category', 'intersection_corner', 'size', 5) AS tags,
-- or
jsonb_build_object(
'size',
((tags ->> 'width')::float / 2)::float,
'category',
'driveway',
'highway',
tags ->> 'highway',
'road',
tags ->> 'road',
'width',
tags ->> 'width'
) AS tags,
jsonb_build_object(
/* sql-formatter-disable */
'category', 'intersection_corner',
'size', 5
/* sql-formatter-enable */
) AS tags,
-- and
jsonb_build_object(
/* sql-formatter-disable */
'size', ((tags ->> 'width')::float / 2)::float,
'category', 'driveway',
'highway', tags ->> 'highway',
'road', tags ->> 'road',
'width', tags ->> 'width'
/* sql-formatter-enable */
) AS tags,
Why do you want this feature?
JSON always uses a key: value pattern to show it's data.
It would be a lot easier for me quickly parse the SQL if the formatter use a similar pattern (even though the jsonb_build_object lists all keys and values in one big list…)
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
The issue does not name an implementation file, entry point, or test; begin by locating the formatter logic and existing tests for function-call arguments. Done means jsonb_build_object key/value arguments can be formatted on paired lines as requested without affecting other SQL formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100