-
-
Notifications
You must be signed in to change notification settings - Fork 211
Open
Description
Describe the feature
For integer primary keys, gorm:"primaryKey" should behave like gorm:"primaryKey;autoIncrement:false" instead of gorm:"primaryKey;autoIncrement:true".
Motivation
- The default behaviour for
gorm.Modelis soft deletion. As soft deleted records persist, there's no need forAUTOINCREMENTuse as in this case no key values are deleted and thus cannot be reused. - When a record gets deleted with
Unscoped,AUTOINCREMENTprevents reuse of the record'sROWIDfor future records, this may or may not be desired depending on a particular use case. - Use of
AUTOINCREMENTis discouraged by SQLite creators due to its performance overhead.
Given the above, I think changing the default behaviour of gorm:"primaryKey" would be beneficial as the use of AUTOINCREMENT is unnecessary in most cases.
Related Issues
Metadata
Metadata
Assignees
Labels
No labels