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

query builder: variables are generated in the wrong scope #925

Open
mrmntte opened this issue Mar 27, 2024 · 1 comment
Open

query builder: variables are generated in the wrong scope #925

mrmntte opened this issue Mar 27, 2024 · 1 comment
Labels

Comments

@mrmntte
Copy link

mrmntte commented Mar 27, 2024

Code
The code causing the error.

      const listQuery = e.select(e.User, () => ({
        limit: 10, // ⚠️ without this the query is generated correctly
      }))
      const resolverQuery = e.with([listQuery], e.select({
        edges: e.select(listQuery, (scope) => ({
          cursor: scope.id,
          node: e.select(scope, {
            id: true,
            handle: true
          })
        }))
      }))

Generated EdgeQL

WITH
  __withVar_3 := (
    WITH
      __scope_2_defaultUser := DETACHED default::User
    SELECT __scope_2_defaultUser {
      id
    }
    LIMIT __withVar_4
  )
SELECT {
  multi edges := (
    WITH
      __withVar_4 := 10,
      __scope_0_defaultUser := __withVar_3
    SELECT __scope_0_defaultUser {
      single cursor := __scope_0_defaultUser.id,
      single node := (
        WITH
          __scope_1_defaultUser := __scope_0_defaultUser
        SELECT __scope_1_defaultUser {
          id,
          handle
        }
      )
    }
  )
}

*Error:

InvalidReferenceError: object type or alias 'default::__withVar_4' does not exist
" 8 |     LIMIT __withVar_4",
 "  |           ^^^^^^^^^^^",

Versions:

  • EdgeDB version: 4.6+0632dff
  • EdgeDB CLI version: EdgeDB CLI 4.0.0-alpha.1+dce7814
  • edgedb-js version: 1.4.1
  • Node/Deno version: 21.5.0
@scotttrinh scotttrinh added the bug label Mar 27, 2024
@awerlogus
Copy link

Duplicate of #808

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

No branches or pull requests

3 participants