Bad indentation for CTE and `Count(*) AS` in return query statement
Open
Nobody has claimed this yet.
- Dominant language
- PLpgSQL
- Stars
- 2k
- Forks
- 121
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 7
Description
Here is the code been formatted
CREATE FUNCTION get_jobs (orgId varchar, pagesize integer, pagenum integer)
RETURNS TABLE (
job_id varchar)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY WITH filtered_jobs AS (
SELECT
j.id AS job_id
FROM
jobs j
ORDER BY
j.created_at DESC
LIMIT pageSize OFFSET pageSize * (pageNum - 1)
),
subtask AS (
SELECT
fj.job_id
FROM
filtered_jobs fj
),
counts AS (
SELECT
ss.job_id,
COUNT(*) AS num,
COUNT(*) AS total_sub_tasks
FROM
subtask ss
)
SELECT
j.job_id
FROM
filtered_jobs j
END;
$$;
One issue is subtask AS ( is not properly indentened. Similar to #213
The other issue is COUNT(*) AS total_sub_tasks .
Contributor guide
No contributing guide indexed for this repository
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
Compare the formatted SQL in the issue with the indentation problem described for subtask AS ( and the COUNT(*) AS total_sub_tasks line. Review the related discussion in issue #213 and use the shown query as the expected formatting case; done means both constructs are indented consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql
- Domain
- databases, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100