Skip to content

Commit

Permalink
fix: allow zeroing out asset ids (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
hay-kot committed Nov 16, 2023
1 parent afbc6a4 commit 8cc0f30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions backend/internal/data/repo/asset_id_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (aid AssetID) MarshalJSON() ([]byte, error) {
}

func (aid *AssetID) UnmarshalJSON(d []byte) error {
if len(d) == 0 || bytes.Equal(d, []byte(`""`)) {
*aid = -1
return nil
}

d = bytes.Replace(d, []byte(`"`), []byte(``), -1)
d = bytes.Replace(d, []byte(`-`), []byte(``), -1)

Expand Down
2 changes: 1 addition & 1 deletion backend/internal/data/repo/repo_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type (
ItemUpdate struct {
ParentID uuid.UUID `json:"parentId" extensions:"x-nullable,x-omitempty"`
ID uuid.UUID `json:"id"`
AssetID AssetID `json:"assetId,string"`
AssetID AssetID `json:"assetId"`
Name string `json:"name"`
Description string `json:"description"`
Quantity int `json:"quantity"`
Expand Down

0 comments on commit 8cc0f30

Please sign in to comment.