go-gorm / playground

GORM Playground (Please Create PR for this project to report issues)
MIT License
89 stars 685 forks source link

Demonstrate null scanning issue #686

Open turip opened 8 months ago

turip commented 8 months ago

The example creates a database then a table with two columns: ID and Value.

I add rows, ID is sequential, value is either ID or NULL:

Then I use gorm's scanrows to scan the data into the same struct, I would expect that for odd rows value will be 0, for even rows value will match ID.

Starting from v1.25.1 this is not the case, and Null columns are just ignored.

Usage

Just execute test.sh to run it against different versions of gorm.

See testlog for run results.

Run results

Testing with gorm v1.23.9
gorm-v1.23.9:PASS
Testing with gorm v1.24.6
gorm-v1.24.6:PASS
Testing with gorm v1.25.0
gorm-v1.25.0:PASS
Testing with gorm v1.25.1
gorm-v1.25.1:MISSMATCH: id=3 value=2 expected_value=0
gorm-v1.25.1:MISSMATCH: id=5 value=4 expected_value=0
....
turip commented 8 months ago

Due to the depency changes, I haven't created a test, but based on the code it should be pretty straightforward.