A question, I specifies a `username` field `unique...
# orm-help
k
A question, I specifies a
username
field
unique
, and
id
is
serial
. OK. Now when I insert
{ username: 'Ali' }
, It will be inserted and in the response I get
{id: 1, username: 'Ali'}
and I try to insert it again, database will yells and says that username is duplicate. So I try something else -
{ username: 'Mohammad' }
- and this time it will be inserted but I realized something weird and strange, The response will be
{id: 3, username: 'Mohammad' }
. Why? Why
id
jumps one number (The number 2 is missed, Number 2 was the duplicate
username
)? Any though? • IMO this is not a good thing.
I discovered It is what Postgres does for us And we have conf to disable it. But keep this in mind that Postgres dev team had some thoughts on this. So please do some R&D on this before disabling it. In my case I stick to the default behavior.
šŸ‘ 1
n
Hey Kasir šŸ‘‹ Thank you for the follow up reply šŸ™Œ Configuration of this setting should be done based on specific use cases but I would suggest default behaviour as well.