Answer the question
In order to leave comments, you need to log in
Autoincrement in INSERT INTO ... ON CONFLICT?
Hello. With INSERT INTO ... ON CONFLICT , auto-creation is triggered for every record. nextval('dishes_products_norms_id_seq'::regclass) . And already at an insertion there is a gap in id.
For example, the first insert. Records are missing and are inserted into the database.
INSERT INTO dishes_products_norms ( dish_id,product_id,children_category_id,amount ) VALUES ( 980190962,28,6,0.02 ),( 980190962,33,6,0.02 ) ON CONFLICT ( dish_id, product_id, children_category_id ) DO UPDATE SET amount = EXCLUDED.amount RETURNING id ;
"ids": [
129,
130
]
INSERT INTO dishes_products_norms ( dish_id,product_id,children_category_id,amount ) VALUES ( 980190962,28,6,0.03 ),( 980190962,33,6,0.02 ) ON CONFLICT ( dish_id, product_id, children_category_id ) DO UPDATE SET amount = EXCLUDED.amount RETURNING id ;
"ids": [
129,
132
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question