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

Query builder: support enum types in params

Open colinhacks opened this issue 3 years ago • 1 comments

colinhacks avatar Jun 13 '22 17:06 colinhacks

Closing because this seems to be a protocol limitation currently.

edgedb> insert NewPost {
.......   title := "asdf", 
.......   content:= "asdf", 
.......   status := <NewPostStatus>$status
....... };
Unimplemented input type descriptor: Enumeration(EnumerationTypeDescriptor { id: fc8a9758-134f-11ed-913b-57df942d0b53, members: ["Published", "Draft"] })

This can be achieved by casting a string parameter to the enum type.

e.params({ status: e.str }, $ => e.insert(e.Post, {
  status: e.cast(e.Status, $.status)
}))

colinhacks avatar Aug 03 '22 21:08 colinhacks

@colinhacks I believe this issue can be closed, as the enum param works in the TS client: https://github.com/MiroslavPetrik/edgedb-vs-knex/blob/main/edgedb/src/queries/helpers/insertTaskAction.ts#L4

image

The error with Unimplemented input type is common - the reason is the REPL client is missing the implementations for various inputs: https://github.com/edgedb/edgedb-cli/issues/821

MiroslavPetrik avatar Nov 13 '22 15:11 MiroslavPetrik