Tags: Vinovest/go-money
Tags
RhymondGH-44 implement driver.Valuer and sql.Scanner for Amount and C… …urrency (Rhymond#99) * RhymondGH-44 implement driver.Valuer and sql.Scanner for money.Currency This allows any Golang ORM which supports the sql.Scanner to serialize (via sql.Driver) and deserialize (via sql.Scanner) a money.Currency instance. money.Amount is now a type alias to int64 which is already supported by sql.Scanner as one of the core built-in data types * RhymondGH-44 implement driver.Value and sql.Scanner for money.Money Money's Value() function enables compatible sql drivers to serialize a money.Money instance to a single comma-delimited string value of "amount,currency_code" Money's Scan() function assumes that it receives a single column where the src value is a comma- delimited string in the format "amount,currency_code" While the storage format is up to the client when the amount and currency are stored separately a compatible scanner value can be created in SQLite like this: SELECT amount || "," || currency as 'amount' It is left to the client to decide to use Money's Valuer implementation with a db annotation on a property of type Money or else to store the Amount and Currency values as two separate columns and return them as a single joined string field. * RhymondGH-44 fix an edge case strings.Split(src,,) will return a slice with length 2 even if one of the strings is empty * fix: money.value tests * refactor out the currency separator and make it customizable clients can set money.DBMoneyValueSeparator to determine which separator (e.g. "," "|" ";" ":" "AS" etc) to use when creating a single driver.Value object to represent a money.Money instance as a single string database field. this allows the money package to support string values such as 10@USD 20;CAD 30|IRD 40 in GBP etc --------- Co-authored-by: Raymond <[email protected]>
Use appropriate number symbol for ZWL. ZWD should have unique code cu… …rrency. (Rhymond#133)
PreviousNext