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@xxxxxxxxxxx