Doctrine + Postgres duplicate records on insert #11029
Unanswered
JPradaa
asked this question in
Support Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone
I'm starting a project with Symfony 6.3 and Postgres 14
When I create a new entity and save it in the DB using "persist" and "flush" 2 identical records are created in the DB
Controller
Entity
Using MySQL the same code inserts a single record, but with Postgres 2 records are inserted
The biggest difference I see is that Doctrine, in the case of Postgres, performs a
SELECT NEXTVAL('live.client_id_seq')
to get the next value in the sequence and generate an INSERT using that value, instead of leaving that task to the DB
INSERT INTO live.client (id, name, code) VALUES (25, 'Cliente name', 'CLIENT_CODE')
I have tried it on Windows and Linux, using different versions of Symfony 6.x, ... and in all cases I get the same result
If once the page is loaded (and 2 records created in the CLIENT table) I go to the profiler and later return to the page using the browser's "back" button, then only 1 record is inserted instead of 2
Does anyone know what could be happening and how to fix the problem?
Thank you very much for your help
All the best
Beta Was this translation helpful? Give feedback.
All reactions