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

Demonstrate null scanning issue #686

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Demonstrate null scanning issue #686

wants to merge 3 commits into from

Conversation

turip
Copy link

@turip turip commented Feb 2, 2024

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:

  • ID: 1, Value: NULL
  • ID: 2, Value: 2
  • ID: 3, Value: 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
Copy link
Author

turip commented Feb 2, 2024

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

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.

1 participant