Handle duplicate key and language pairs when updating translations

Đang mở
#274 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, spring-boot, sql
Lĩnh vực
backend, database

Hướng nghiên cứu

Start with updateByi18nId in template/springboot/src/main/java/com/TinyPro/service/imp/II18ServiceImpl.java and compare it with the create flow, which already throws exception.i18.exists. Check I18Repository.java for a lookup by key and language, then confirm the uk_i18_lang_key constraint in I18.java. Done means a conflicting update returns HTTP 400 with exception.i18.exists, a self-update or unused key still saves, and regression tests cover both.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Follow up on the review finding in PR #265: updating a translation to a key and language pair used by another translation should return a controlled validation error rather than an internal server error.

Requested by @msslulu. The requester chose to leave the existing logic unchanged in PR #265 and agreed to track this work in a separate issue.

Required changes

  • Verify the current updateByi18nId behavior in template/springboot/src/main/java/com/TinyPro/service/imp/II18ServiceImpl.java.
  • Before saving an update, check whether another translation has the requested key and language. Exclude the translation being updated.
  • If a conflict exists, throw exception.i18.exists with HttpStatus.BAD_REQUEST, matching the create flow.
  • Keep the uk_i18_lang_key unique constraint and preserve the save flow for non-conflicting updates.
  • Add regression coverage for conflicting and non-conflicting updates.

Rationale

The review reported that duplicate updates fail at transaction commit with HTTP 500, while the create flow returns HTTP 400 with exception.i18.exists. Consistent conflict handling gives API clients an actionable error.

Affected areas

  • template/springboot/src/main/java/com/TinyPro/service/imp/II18ServiceImpl.java
  • template/springboot/src/main/java/com/TinyPro/jpa/I18Repository.java
  • template/springboot/src/main/java/com/TinyPro/entity/po/I18.java
  • Translation service/controller tests as appropriate.

Acceptance criteria

  • Updating a translation to another translation's key and language returns HTTP 400 with exception.i18.exists.
  • Updating a translation without changing its own key and language does not produce a false conflict.
  • Updating to an unused key and language succeeds.
  • A rejected update does not change the stored translation.
  • The database unique constraint remains in place.
  • Regression tests cover these cases.

References

Ngôn ngữ chính
TypeScript
Star
88
Fork
29
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opentiny/tiny-pro

Tất cả issue của opentiny/tiny-pro

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.