edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

QueryError: cannot assign to __type__

Open haikyuu opened this issue 3 years ago • 1 comments

I'm running the following query using the query builder.

const query = e.select(e.Entity, ()=> ({ name: true, __type__: { id: true, name: true }}))

But I'm getting the following error

QueryError: cannot assign to __type__
    at RawConnection._parseErrorMessage (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/baseConn.js:276:21)
    at RawConnection._parse (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/baseConn.js:418:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RawConnection.fetch (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/baseConn.js:698:61)
    at async ClientConnectionHolder.retryingFetch (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/client.js:178:26)
    at async Client.query (/Users/abdellah/workspace/scrimba/scrimba-data-playground/node_modules/edgedb/dist/client.js:468:20)
    at Datahose.subscribe (/Users/abdellah/workspace/scrimba/scrimba-data-playground/app/lib/datahose.imba:93:22) {
  source: undefined
}

Here is the query generated by the query builder:

'WITH  __scope_0_Entity := DETACHED default::Entity
SELECT __scope_0_Entity {  
id,  
name,  
__type__ := (    WITH      __scope_1_Type := __scope_0_Entity.__type__    SELECT __scope_1_Type {      name    }  )
}

And the query itself fails in edgedb

haikyuu avatar Apr 11 '22 05:04 haikyuu

Ran into the same issue.

I was able to extract the information in a different way:

const query = e.select(e.Entity, (dbEntity)=> ({ name: true, type: dbEntity.__type__.name }))

OriginalEXE avatar Apr 15 '22 16:04 OriginalEXE

This appears to be fixed in the latest version and has test coverage.

scotttrinh avatar May 02 '23 14:05 scotttrinh