Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Commit 8cc0f30

Browse files
authored
fix: allow zeroing out asset ids (#624)
1 parent afbc6a4 commit 8cc0f30

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: backend/internal/data/repo/asset_id_type.go

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func (aid AssetID) MarshalJSON() ([]byte, error) {
4747
}
4848

4949
func (aid *AssetID) UnmarshalJSON(d []byte) error {
50+
if len(d) == 0 || bytes.Equal(d, []byte(`""`)) {
51+
*aid = -1
52+
return nil
53+
}
54+
5055
d = bytes.Replace(d, []byte(`"`), []byte(``), -1)
5156
d = bytes.Replace(d, []byte(`-`), []byte(``), -1)
5257

Diff for: backend/internal/data/repo/repo_items.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type (
6868
ItemUpdate struct {
6969
ParentID uuid.UUID `json:"parentId" extensions:"x-nullable,x-omitempty"`
7070
ID uuid.UUID `json:"id"`
71-
AssetID AssetID `json:"assetId,string"`
71+
AssetID AssetID `json:"assetId"`
7272
Name string `json:"name"`
7373
Description string `json:"description"`
7474
Quantity int `json:"quantity"`

0 commit comments

Comments
 (0)