Skip to content

Commit 6c6d08e

Browse files
saeideeSaeid Saeidee
andauthored
fix: error translation casting (#103)
Co-authored-by: Saeid Saeidee <[email protected]>
1 parent 3ddd178 commit 6c6d08e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

error_translator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"gorm.io/gorm"
77
)
88

9+
// The error codes to map mssql errors to gorm errors, here is a reference about error codes for mssql https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors?view=sql-server-ver16
910
var errCodes = map[string]int32{
1011
"uniqueConstraint": 2627,
1112
}
@@ -17,7 +18,7 @@ type ErrMessage struct {
1718

1819
// Translate it will translate the error to native gorm errors.
1920
func (dialector Dialector) Translate(err error) error {
20-
if mssqlErr, ok := err.(*mssql.Error); ok {
21+
if mssqlErr, ok := err.(mssql.Error); ok {
2122
if mssqlErr.Number == errCodes["uniqueConstraint"] {
2223
return gorm.ErrDuplicatedKey
2324
}

0 commit comments

Comments
 (0)