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

[NEOS-1075] Unable to subset table that includes json column #1910

Closed
nickzelei opened this issue May 3, 2024 · 0 comments
Closed

[NEOS-1075] Unable to subset table that includes json column #1910

nickzelei opened this issue May 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working HackerNews Launch Created by Linear-GitHub Sync
Milestone

Comments

@nickzelei
Copy link
Member

See this thread for more details:

https://discord.com/channels/1171894401140797591/1235948472784523284

Repro steps:
steps that should repro it:

  • create a table with one of the columns that is a FK to the PKey of that table (so like a "parent record" relationship)
  • create a json (not jsonb) type column
  • run in subset mode (not exactly sure if you need to have the subset where clause link back or not)

Bad Query:

WITH RECURSIVE related AS (
    SELECT
        public.table_name.id,
        public.table_name.parent_record_id,
        public.table_name.json_col
    FROM
        public.table_name
    UNION
    (
        SELECT
            public.table_name.id,
            public.table_name.parent_record_id,
            public.table_name.json_col
        FROM
            public.table_name
            INNER JOIN related ON (
                public.table_name.id = related.parent_record_id
            )
    )
)
SELECT
    DISTINCT id,
    parent_record_id,
    json_col
FROM
    related;

Working Query:

WITH RECURSIVE related AS (
    SELECT
        public.table_name.id,
        to_jsonb(public.table_name.json_col) as im,
        public.table_name.parent_id
    FROM
        public.table_name
    UNION
    (
        SELECT
            public.table_name.id,
            to_jsonb(public.table_name.json_col) as im,
            public.table_name.parent_id
        FROM
            public.table_name
            INNER JOIN related ON (
                public.table_name.id = related.parent_id
            )
    )
)
SELECT
    DISTINCT id,
    im,
    parent_id
FROM
    related

From SyncLinear.com | NEOS-1075

@nickzelei nickzelei added bug Something isn't working HackerNews Launch Created by Linear-GitHub Sync labels May 3, 2024
@nickzelei nickzelei added this to the v.19 milestone May 6, 2024
@nickzelei nickzelei modified the milestones: v.19, v.20 May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working HackerNews Launch Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

2 participants