forked from denisenkom/go-mssqldb
- Notifications
You must be signed in to change notification settings - Fork 88
Shopspring decimal support #287
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
Open
El-76 wants to merge 51 commits into microsoft:main Choose a base branch from El-76:shopspring-decimal-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
51 commits Select commit Hold shift + click to select a range
355b82d Queries and parameters tests.
El-76 b222140 OUT parameter tests.
El-76 d2254b6 Bug fix.
El-76 f6d9eef TVP test.
El-76 50e5c43 Bug fix.
El-76 88bd7b5 Another TVP test.
El-76 f180976 Another TVP test.
El-76 861f0f5 Another TVP test.
El-76 f981817 Bug fix.
El-76 00bc87f Bug fix.
El-76 5d9662c Another TVP test.
El-76 2ff7a0f Bulk copy test.
El-76 cfd6a54 Bug fix.
El-76 5b899a8 Bug fix.
El-76 d0484de Another bulk copy test.
El-76 6a6bd7b Bug fix.
El-76 9e653eb Some MONEY type tests.
El-76 e6140e3 Support MONEY type.
El-76 ed539e5 Support Decimal type.
El-76 486afc6 Support NULL for MONEY type.
El-76 d829e40 Merge branch 'shopspring-decimal-support' of github.com:El-76/go-mssq…
El-76 185d6a5 Bug fix and more tests.
El-76 f16aae0 MONEY encoding test.
El-76 8a648d4 Bug fix.
El-76 ccb0e19 Query MONEY encoding test.
El-76 6f3d11d Bug fix.
El-76 8fa6a7e Query MONEY encoding tests.
El-76 5907498 DECIMAL encoding tests.
El-76 31824d4 Bug fix.
El-76 12227f8 Bulk copy money tests.
El-76 0432834 Bug fix.
El-76 cbadbf4 Money bulkcopy support.
El-76 c5b2963 Bug fix.
El-76 cd6ea2b SMALLMONEY bulkcopy support.
El-76 07b5e6a Bug fix.
El-76 be4c83c Bug fix.
El-76 acbd807 Refactoring - generalize Money type wrapper.
El-76 a1249b2 Bug fix.
El-76 fc14ce1 TVP MONEY test.
El-76 fb27c6f TVP MONEY test.
El-76 b95ed9f TVP MONEY test.
El-76 b4909d5 TVP MONEY test.
El-76 a81a8d5 Remove redundant file.
El-76 b832815 Simplify money encoding.
El-76 bcc0a71 Money test.
El-76 ab7caa3 More money tests.
El-76 ac07725 Merge branch 'main' into shopspring-decimal-support
El-76 7cbd01e Remove redundant file.
El-76 7e61f6b Update README.
El-76 afc1a1a Money / bulk tests - error cases.
El-76 09a3511 Merge branch 'main' into shopspring-decimal-support
El-76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package mssql | ||
| | ||
| import ( | ||
| "database/sql" | ||
| "database/sql/driver" | ||
| | ||
| "github.com/shopspring/decimal" | ||
| ) | ||
| | ||
| type Money[D decimal.Decimal|decimal.NullDecimal] struct { | ||
| Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. | ||
| Decimal D | ||
| } | ||
| | ||
| func (m Money[D]) Value() (driver.Value, error) { | ||
| valuer, _ := any(m.Decimal).(driver.Valuer) | ||
| | ||
| return valuer.Value() | ||
| } | ||
| | ||
| func (m *Money[D]) Scan(v any) error { | ||
| scanner, _ := any(&m.Decimal).(sql.Scanner) | ||
| | ||
| return scanner.Scan(v); | ||
| ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
it's nice that this module doesn't bring it a bunch of other stuff.
It'd be nice if the driver supported a pluggable type system like we support different network protocols for SQL connections so apps could include the module of their choice to get the implementation. #Resolved
Uh oh!
There was an error while loading. Please reload this page.
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.
I think there is already some work done in sql library itself, but its still considered experimental, see: golang/go#30870 .
Source code: