go-mssqldb icon indicating copy to clipboard operation
go-mssqldb copied to clipboard

bulkcopy: mssql: type 6e not implemented

Open subhransus2 opened this issue 5 years ago • 3 comments

When I am trying to perform bulk insert in my project, I found an error like below. error="bulkcopy: mssql: type 6e not implemented"

After debugging the issue I found that, there is no code in the package for managing the data type of money. Please check the bulkcopy.go file line 456. The case for handling money type is commented there. // case typeMoney, typeMoney4, typeMoneyN:

As my database table contains some fields of money type, so I got above error. Can you please suggest how to manage data if the database contains field of type money?

subhransus2 avatar Mar 28 '19 10:03 subhransus2

There is an open PR to fix this. It is waiting until I resolve how to make decimals work.

Out of curiosity, what Go type are you using to represent your Money type?

kardianos avatar Mar 28 '19 14:03 kardianos

For now I am using float32 for Money type, also tried float64 previously.

subhransus2 avatar Mar 28 '19 17:03 subhransus2

For easier reference: https://github.com/denisenkom/go-mssqldb/blob/master/bulkcopy.go#L504

My five cents:

On "Out of curiosity, what Go type are you using to represent your Money type?", I guess, sth similar to what is supported for decimal: ints, floats and string. The implementation for decimals converts parameters to the var dec decimal.Decimal but it doesn't not support decimal.Decimal itself b/c that's an internal type. IMHO it should be considered to make this type public to provide an option for pulling out the conversion into the client.

As far as I remember the reason for using money was to enable precise 8byte calculations with four fixed decimal digits and a lot of valid digits before the decimal point for very large amounts of money. Float64 is quite nasty in comparison.

Lercher avatar Dec 19 '23 15:12 Lercher