Skip to content

Conversation

@ChandlerSwift
Copy link
Contributor

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

PR #202 made an equivalent change to .Scan() previously:

commit 56bb801c8a4fdb3b3cda295fd2766d87834c455d
Author: Long Le <[email protected]>
Date:   Tue Apr 11 10:17:44 2023 +0700

    Use json.Number when scan to JSONMap (#202)

This commit makes the equivalent change to .UnmarshalJSON, so that the value is consistently correct whether it originates in the database or in a JSON object to be decoded.

This commit also adds a test validating that, which fails without this commit:

$ go test ./...
2025/10/23 16:06:37 testing sqlite3...
--- FAIL: TestJSONMap_Unmarshal (0.00s)
    utils.go:40: datatypes/json_map_test.go:193: expect: 1085238870184050699, got 1085238870184050688

but passes with this commit.

User Case Description

A json.Unmarshal()ed value should be of the same type as a value Scan()ned from the database.

PR go-gorm#202 made an equivalent change to .Scan() previously:

    commit 56bb801
    Author: Long Le <[email protected]>
    Date:   Tue Apr 11 10:17:44 2023 +0700

        Use json.Number when scan to JSONMap (go-gorm#202)

This commit makes the equivalent change to .UnmarshalJSON, so that the
value is consistently correct whether it originates in the database or
in a JSON object to be decoded.

This commit also adds a test validating that, which fails without this
commit:

    $ go test ./...
    2025/10/23 16:06:37 testing sqlite3...
    --- FAIL: TestJSONMap_Unmarshal (0.00s)
        utils.go:40: datatypes/json_map_test.go:193: expect: 1085238870184050699, got 1085238870184050688

but passes with this commit.

Co-Authored-By: Jeff Smith <[email protected]>
@jinzhu jinzhu merged commit 575f7be into go-gorm:master Oct 26, 2025
27 checks passed
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

Successfully merging this pull request may close these issues.

2 participants