replace retval of ToDB with `{}interface(nil)` #1044

Closed
koron wants to merge 1 commits from koron/nullable-ToDB into master
koron commented 3 years ago (Migrated from github.com)
Owner

instead of []byte(nil).

current custom types can't be set to NULL.
because some drivers (like lib/pq) don't consider that []byte(nil) is NULL . when ToDB() return nil, it is []byte(nil).

This PR checks return values from ToDB(), and when it is []byte(nil)
translates those to {}interface(nil). it is treated as NULL

instead of `[]byte(nil)`. current custom types can't be set to `NULL`. because some drivers ([like lib/pq](https://github.com/lib/pq/issues/773)) don't consider that `[]byte(nil)` is NULL . when `ToDB()` return `nil`, it is `[]byte(nil)`. This PR checks return values from `ToDB()`, and when it is `[]byte(nil)` translates those to `{}interface(nil)`. it is treated as `NULL`
codecov-io commented 3 years ago (Migrated from github.com)
Owner

Codecov Report

Merging #1044 into master will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1044      +/-   ##
==========================================
- Coverage   54.28%   54.24%   -0.05%     
==========================================
  Files          41       41              
  Lines        7551     7557       +6     
==========================================
  Hits         4099     4099              
- Misses       2936     2941       +5     
- Partials      516      517       +1
Impacted Files Coverage Δ
session_convert.go 22.1% <0%> (-0.19%) ⬇️
statement.go 66.66% <0%> (-0.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad69f7d...19b2069. Read the comment docs.

# [Codecov](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=h1) Report > Merging [#1044](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=desc) into [master](https://codecov.io/gh/go-xorm/xorm/commit/ad69f7d8f0861a29438154bb0a20b60501298480?src=pr&el=desc) will **decrease** coverage by `0.04%`. > The diff coverage is `0%`. [![Impacted file tree graph](https://codecov.io/gh/go-xorm/xorm/pull/1044/graphs/tree.svg?height=150&width=650&token=yB5nO1krEe&src=pr)](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=tree) ```diff @@ Coverage Diff @@ ## master #1044 +/- ## ========================================== - Coverage 54.28% 54.24% -0.05% ========================================== Files 41 41 Lines 7551 7557 +6 ========================================== Hits 4099 4099 - Misses 2936 2941 +5 - Partials 516 517 +1 ``` | [Impacted Files](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=tree) | Coverage Δ | | |---|---|---| | [session\_convert.go](https://codecov.io/gh/go-xorm/xorm/pull/1044/diff?src=pr&el=tree#diff-c2Vzc2lvbl9jb252ZXJ0Lmdv) | `22.1% <0%> (-0.19%)` | :arrow_down: | | [statement.go](https://codecov.io/gh/go-xorm/xorm/pull/1044/diff?src=pr&el=tree#diff-c3RhdGVtZW50Lmdv) | `66.66% <0%> (-0.18%)` | :arrow_down: | ------ [Continue to review full report at Codecov](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=continue). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta) > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=footer). Last update [ad69f7d...19b2069](https://codecov.io/gh/go-xorm/xorm/pull/1044?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
lunny added the
kind/enhancement
label 2 years ago
lunny added this to the 1.1.1 milestone 2 years ago
lunny referenced this issue from a commit 6 months ago
lunny removed this from the 1.1.1 milestone 6 months ago
lunny closed this pull request 6 months ago
lunny deleted branch koron/nullable-ToDB 6 months ago
lunny referenced this issue from a commit 5 months ago
This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
Loading…
There is no content yet.