Skip to content

fix server not detecting conflicts on duplicated names #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2025

Conversation

Eslam-Nawara
Copy link
Collaborator

Description

fix server not detecting conflicts on duplicated names

Related Issues

List of related issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

@@ -41,9 +43,10 @@ func (db *Database) GetFarm(farmID uint64) (farm Farm, err error) {

func (db *Database) CreateFarm(farm Farm) (uint64, error) {
if err := db.gormDB.Create(&farm).Error; err != nil {
if errors.Is(err, gorm.ErrDuplicatedKey) {
if errors.Is(err, gorm.ErrDuplicatedKey) || strings.Contains(err.Error(), "23505") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if checking on the error code would be better

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to match against pq.ErrorCode but it didn't work so I matched strings

@Eslam-Nawara Eslam-Nawara force-pushed the development-fix-farm-name-conflict branch 2 times, most recently from 0aa5c79 to 681a04a Compare March 20, 2025 14:59
@Eslam-Nawara Eslam-Nawara force-pushed the development-fix-farm-name-conflict branch from 681a04a to 421cb93 Compare April 6, 2025 10:45
@Eslam-Nawara Eslam-Nawara force-pushed the development-fix-farm-name-conflict branch from 7ca3232 to c164805 Compare April 6, 2025 10:48
@Eslam-Nawara Eslam-Nawara merged commit 44106af into development Apr 6, 2025
4 checks passed
@Eslam-Nawara Eslam-Nawara deleted the development-fix-farm-name-conflict branch April 6, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants