orm icon indicating copy to clipboard operation
orm copied to clipboard

Create and friends ignore setting the PK

Open coderanger opened this issue 2 years ago • 3 comments

Creating a row with a manually-specified PK isn't super common but it does happen and should be supported one way or another.

coderanger avatar Jun 14 '22 23:06 coderanger

Upvoting.

AnirvanB avatar Aug 11 '22 17:08 AnirvanB

according to #143, this was intentional

nexy7574 avatar Aug 27 '22 16:08 nexy7574

I agree, you can have a primary key index on a column that doesn't have AUTO_INCREMENT set. An ability to allow setting the value in such cases is mandatory, otherwise there's no way to create that entry via ORM.

Given this comment:

if you find maybe Django or SQLAlchemy have a different behaviour, we could change it.

I can confirm that Django's ORM allows settings a value for a primary_key column at creation time (I'm using that in one of my applications).

roks0n avatar May 16 '23 21:05 roks0n