Closed shomodj closed 2 years ago
Actually, ids are always fetched by default, they're just not included in the repr
:
>>> conn.query('insert Hero')[0].id
UUID('5b214b7a-c7fd-11ec-8145-dfc85a3fcb32')
If you want to select other fields, wrap insert
into a select
:
select (
insert Hero {
name := "Spider-Man",
secret_identity := "Peter Parker"
}
) {
id,
name,
secret_identity,
};
A more readable formulation would be using a with
clause:
with
NewHero := (
insert Hero {
name := "Spider-Man",
secret_identity := "Peter Parker"
}
)
select
NewHero {
id,
name,
secret_identity,
}
@shomodj thanks, It's the repr
fault ;) I'll update the docs, this info is valuable.
I'm looking at the INSERT snippet from the https://www.edgedb.com/docs/edgeql/insert#basic-usage
and it looks to me that EdgeDB returns an object ID on the CLI, but when I run it from Python I get
Basically, I want to do what Postgres does at https://www.postgresql.org/docs/current/dml-returning.html
Is this possible?
Thanks.