go-gorm / sqlite

GORM sqlite driver
MIT License
179 stars 184 forks source link

fix: translate SQLITE_CONSTRAINT_PRIMARYKEY to ErrDuplicatedKey #152

Closed bfabio closed 1 year ago

bfabio commented 1 year ago

What did this pull request do?

Translate the SQLITE_CONSTRAINT_PRIMARYKEY error code to ErrDuplicatedKey as well for consistency.

User Case Description

We refactored our code to take advantage of ErrDuplicatedKey, but the tests fail because ErrDuplicatedKey only gets returned for non primary key fields (and it should IMO):

https://github.com/italia/developers-italia-api/pull/197 https://github.com/italia/developers-italia-api/actions/runs/5143820348/jobs/9259314436?pr=197

Also, should this go in https://github.com/go-gorm/postgres and https://github.com/go-gorm/mysql as well?

jinzhu commented 1 year ago

Hi @bfabio

Can you fix the conflicts? thank you

bfabio commented 1 year ago

@jinzhu sure, done