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

test: add a test to capture incorrect after filtering in nested gql c… #494

Conversation

michaelcaulley
Copy link

@michaelcaulley michaelcaulley commented Apr 28, 2023

…onnections

It looks like the where predicate is being assigned to the inner queries in addition to the level it is set on. Here's some example SQL output showing the issue for a query.

QUERY:

query bad {
  node(id: 1) {
    ... on Todo {
      id
      text
      children(after: "gaFpBA") {
        totalCount
        edges {
          cursor
          node {
            id
            text
            children {
              totalCount
              edges {
                node {
                  id
                  text
                }
              }
            }
          }
        }
      }
    }
  }
}

SQL OUTPUT:

SELECT `users`.`id`, `users`.`name`
FROM `users`
WHERE `users`.`id` = 4294967297
LIMIT 2;


WITH `src_query` AS (SELECT `users`.`id`, `users`.`name`, `users`.`manager_id`
                     FROM `users`
                     WHERE `users`.`id` > 4294967298
                       AND `users`.`manager_id` IN (4294967297)),
     `limited_query` AS (SELECT *,
                                (ROW_NUMBER() OVER (PARTITION BY `manager_id` ORDER BY `id` ASC)) AS `row_number`
                         FROM `src_query`)
SELECT `id`, `name`, `manager_id`
FROM `limited_query` AS `users`
WHERE `users`.`row_number` <= 3;



WITH `src_query` AS (SELECT `todos`.`id`, `todos`.`text`, `todos`.`owner_id`, `todos`.`todo_parent`
                     FROM `todos`
                     WHERE `todos`.`id` > 4294967298 -- 👈 🚨this is not needed
                       AND `todos`.`owner_id` IN (4294967299, 4294967300, 4294967301)),
     `limited_query` AS (SELECT *,
                                (ROW_NUMBER() OVER (PARTITION BY `owner_id` ORDER BY `id` ASC)) AS `row_number`
                         FROM `src_query`)
SELECT `id`, `text`, `owner_id`, `todo_parent`
FROM `limited_query` AS `todos`
WHERE `todos`.`row_number` <= 3

@a8m
Copy link
Member

a8m commented Apr 29, 2023

Fixed with #495. Thanks, @michaelcaulley 🙏

@a8m a8m closed this Apr 29, 2023
@michaelcaulley
Copy link
Author

@a8m of course. Thank you for the quick attention on this. We've really been enjoying using ent!

@michaelcaulley michaelcaulley deleted the failing-nested-relay-connection-test branch April 30, 2023 16:36
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

Successfully merging this pull request may close these issues.

2 participants