Skip to content

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

@ray-x

Description

@ray-x

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 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions