Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad indentation for CTE and Count(*) AS in return query statement #258

Open
ray-x opened this issue Aug 28, 2021 · 2 comments
Open

Bad indentation for CTE and Count(*) AS in return query statement #258

ray-x opened this issue Aug 28, 2021 · 2 comments

Comments

@ray-x
Copy link

ray-x commented Aug 28, 2021

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 .

@ray-x ray-x changed the title Bad indentation for CTE and Count(*) AS in return query statement Bad indentation for CTE and Count(*) AS in return query statement Aug 28, 2021
@darold
Copy link
Owner

darold commented Sep 28, 2021

Yes there is a major formatting issue with CTE, I'm still missing time to work on it but it is in my todo list.

@jacek0x
Copy link

jacek0x commented May 20, 2022

Yes there is a major formatting issue with CTE, I'm still missing time to work on it but it is in my todo list.

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants