pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thorsten Glaser <tg@evolvis.org>
To: Kirk Wolak <wolakk@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Guidance on INSERT RETURNING order
Date: Thu, 13 Apr 2023 00:24:13 +0200 (CEST)
Message-ID: <c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org> (raw)
In-Reply-To: <CACLU5mQYZY0ZwdTDUE6NTfn=7SbO_JJ5qhttED5xaqkps27kng@mail.gmail.com>
References: <CAN19dycS0oUorLOGgjxMX8NZq-hOA1RJrzwC4L3FxpMf4BQbBQ@mail.gmail.com>
	<95fbd8c8-2f7a-38a1-4a41-b2ac3763d89c@aklaver.com>
	<CAN19dyed0o5eCUYSEq30q39SpFmeZ7WSEHBfR042YYTVoipHcg@mail.gmail.com>
	<CACLU5mT5x-76uy_Rh821-WfnD3Z2iuMsZL4y1dsSBK2ypERcmA@mail.gmail.com>
	<c876553a-18f7-db6e-4972-76961f43a4ce@aklaver.com>
	<CACLU5mQYZY0ZwdTDUE6NTfn=7SbO_JJ5qhttED5xaqkps27kng@mail.gmail.com>

On Wed, 12 Apr 2023, Kirk Wolak wrote:

>The solution exists.  Pre-fetch the IDs, assign them and insert them with
>the IDs.  Then you have 100% control.
>SELECT NEXTVAL('tbl_seq') from GENERATE_SERIES(1, <total_needed>);

This would be a nice solution… but the PK could be always generated,
or not even sequential (UUIDs for example). If you’re developing
schema-first the application would not even (need to) know about how
the IDs are generated as it’s the DB that generates them.

AIUI the OP’s an SQLAlchemy developer, which is an ORM. Therefore he
needs a generic solution.

bye,
//mirabilos
-- 
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)





view thread (56+ messages)  latest in thread

Message-ID: <c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org>
Permalink:  ../c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org/
Also on:    postgresql.org/message-id/c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tg@evolvis.org, wolakk@gmail.com
  Subject: Re: Guidance on INSERT RETURNING order
  In-Reply-To: <c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org>
  References: <CAN19dycS0oUorLOGgjxMX8NZq-hOA1RJrzwC4L3FxpMf4BQbBQ@mail.gmail.com> <95fbd8c8-2f7a-38a1-4a41-b2ac3763d89c@aklaver.com> <CAN19dyed0o5eCUYSEq30q39SpFmeZ7WSEHBfR042YYTVoipHcg@mail.gmail.com> <CACLU5mT5x-76uy_Rh821-WfnD3Z2iuMsZL4y1dsSBK2ypERcmA@mail.gmail.com> <c876553a-18f7-db6e-4972-76961f43a4ce@aklaver.com> <CACLU5mQYZY0ZwdTDUE6NTfn=7SbO_JJ5qhttED5xaqkps27kng@mail.gmail.com> <c422c4ef-a284-e45e-b968-27bff221e993@evolvis.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox