Re: Guidance on INSERT RETURNING order
От | Adrian Klaver |
---|---|
Тема | Re: Guidance on INSERT RETURNING order |
Дата | |
Msg-id | 9b21a499-9352-e1f6-4936-47b024e8b0ef@aklaver.com обсуждение исходный текст |
Ответ на | Guidance on INSERT RETURNING order (Federico <cfederico87@gmail.com>) |
Список | pgsql-general |
On 4/11/23 12:47, Federico wrote: > Hello list, > > I have a few clarification questions regarding using insert with returning. > The use case is SQLAlchemy development, where the orm wants to insert > a list of rows, > get back the generated ids, defaults, etc, and match the returned values with > the original list of orm objects. > > The following assumes a table like this > > CREATE TABLE t( > id SERIAL, > data TEXT -- type here can be anything > ) > > On PostgreSQL, since SQLAlchemy version 1.4 (Mar 2021) this operation has used > > INSERT INTO t(data) VALUES ('a'), ('b'), ('c') RETURNING id > > but we were recently made aware that there is no guarantee on the > order of the returned columns. 1) Because returned data in SQL is inherently unordered. 2) What would you order by, id or data or both? > Sorry for the long email, > Thanks > > Federico > > -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: