Skip to content
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

How to check if tds.Num represents a NULL value #27

Open
hqin opened this issue Jun 26, 2021 · 2 comments
Open

How to check if tds.Num represents a NULL value #27

hqin opened this issue Jun 26, 2021 · 2 comments

Comments

@hqin
Copy link

hqin commented Jun 26, 2021

After scanning successfully a NULL value into tds.Num, what is the public method to determine if is NULL or not? tds.Num has only String() and Rat() methods?

tds.Num{r:big.Rat{a:big.Int{neg:false, abs:big.nat(nil)}, b:big.Int{neg:false, abs:big.nat(nil)}}, precision:0, scale:0, isNull:true}

@thda
Copy link
Owner

thda commented Jun 28, 2021

Thanks for reporting, good catch.
I should add a NullNum type which has a Valid member, similar to NullString.
Another option would be to return a nil pointer when the num is nil.
I'll try to work on it next week.
Out of curiosity, do you know how SAP's official driver handles this ?

@hqin
Copy link
Author

hqin commented Sep 7, 2021

Unfortunately SAP's go-ase driver does not handle it properly either.
FYI, github.com/denisenkom/go-mssqldb handles null decimal using sql.NullString.
github.com/cockroachdb/apd/v2 has apd.Decimal and apd.NullDecimal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants