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

Typescript query builder doesn't support querying link properties of back links

Open ssendev opened this issue 2 years ago • 1 comments

  • EdgeDB Version: 3.0+e7d38e9
  • EdgeDB CLI Version: 3.3.0+071876c
  • OS Version: fedora 38 Steps to Reproduce:
e.select(e.Organisation, (org) => ({
  id: true,
  name: true
  orgs_back: {
    id: true,
    name: true,
    '@label': true // link property '@label' does not exist on link .orgs_back
  },
  orgs_back2: e.select(org['<orgs[is Organisation]'], (orgs_back) => ({
    id: true,
    name: true,
    '@label': true, // link property '@label' does not exist on link <orgs[is Organisation]
    label2: orgs_back['@label'],
    label3: e.select(orgs_back.orgs, (orgs) => ({
      '@label': true, // invalid reference to link property in top level shape
      filter_single: e.op(org.id, '=', orgs.id),
    })),
    label4: e.select(orgs_back.orgs, (orgs) => ({
      label: orgs['@label'],
      filter_single: e.op(org.id, '=', orgs.id),
    })).label, // this typechecks but fails with // cannot find scope statement for (__derived__::expr~21)
    // this works:
    label5: e.select(orgs_back.orgs, (orgs) => ({
      label: orgs['@label'],
      filter_single: e.op(org.id, '=', orgs.id),
    })),
  })),
}))

Schema:

type Organisation {
  name: str,
  multi link orgs: Organisation {
    property label: str;
  }
  multi link orgs_back := (.<orgs[is Organisation]);
}

ssendev avatar Jun 22 '23 19:06 ssendev

Thanks for reporting! I've transferred the issue here since this is related to the TypeScript query builder and not the EdgeDB server or compiler itself.

Turns out this is a duplicate of: #399 #625 https://github.com/edgedb/edgedb-js/issues/428

Looks to be a long-standing issue, but I have #625 on my short-list which might fix the issue in the query builder as well. I'll keep this open while we address it.

scotttrinh avatar Jun 22 '23 19:06 scotttrinh