-
Notifications
You must be signed in to change notification settings - Fork 0
Change product quantity to be a string #18
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,7 +37,7 @@ type Product struct { | |||||
| UniqueScansN int `json:"unique_scans_n" bson:"unique_scans_n,truncate"` | ||||||
| FoodGroupsTags []interface{} `json:"food_groups_tags" bson:"food_groups_tags,truncate"` | ||||||
| States string `json:"states" bson:"states"` | ||||||
| ProductQuantity float64 `json:"product_quantity" bson:"product_quantity,truncate"` | ||||||
| ProductQuantity string `json:"product_quantity" bson:"product_quantity,truncate"` | ||||||
|
||||||
| ProductQuantity string `json:"product_quantity" bson:"product_quantity,truncate"` | |
| ProductQuantity string `json:"product_quantity" bson:"product_quantity"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing
ProductQuantityfromfloat64tostringwill likely break BSON decoding from MongoDB when existing documents storeproduct_quantityas a numeric type (and vice versa if some docs store it as a string). The Go MongoDB driver cannot decode a BSON double/int directly into a Gostring, soFindOne().Decode()/cursor.All()can start failing at runtime for mixed-type data. Consider introducing a dedicated type for this field that implements BSON unmarshalling (and JSON unmarshalling if needed) to accept both string and numeric representations and normalize to a string, rather than switching the struct field to plainstring.