Skip to content

Some expressions can end up with unintended DETACHED #1300

@scotttrinh

Description

@scotttrinh

When attempting to cast a subselect into JSON, this expression generates incorrect EdgeQL

    const q = e.select(e.Movie, (movie) => ({
      node: movie,
      cursor: e.to_str(
        e.cast(
          e.json,
          e.select(movie, () => ({
            id: true,
            release_year: true,
          })),
        ),
      ),
    }));
    WITH
      __scope_0_defaultMovie := DETACHED default::Movie
    SELECT __scope_0_defaultMovie {
      single node := __scope_0_defaultMovie,
      single cursor := (
        std::to_str((<std::json>(SELECT DETACHED default::Movie {
          id,
          release_year
        })))
      )
    }

Notice the DETACHED default::Movie in the sub-select. This should be __scope_0_defaultMovie.

This is a somewhat recent regression since the project rename, so that should narrow the offending issue down to something in our recent updates to the automatic with extraction logic.


Note, that it does work if you return a Free Object instead of the subselect:

    const q = e.select(e.Movie, (movie) => ({
      node: movie,
      cursor: e.to_str(
        e.cast(
          e.json,
          e.select({
            id: movie.id,
            release_year: movie.release_year,
          }),
        ),
      ),
    }));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions