-
Notifications
You must be signed in to change notification settings - Fork 292
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
Fix rowversion null behaviour #998
Conversation
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.
LGTM
No tests?? |
The appcontext switch is process global so I couldn't deterministically make sure that it turned on and off for the right tests. It's also a trivial change tested locally so it didn't seem worth doing lots of private reflection. |
I think it should be possible to turn on an appcontext switch as part of the test (i.e. AppContext.SetSwitch), and back off at the end of it; take care to also disable parallelization for that test to avoid affecting other tests running in parallel. (no idea on whether testing is important for this particular case etc.) |
But it should be possible to add a test to confirm the new changed default behaviour? Or do I misunderstand? |
If I can find how to prevent the tests running in parallel as @roji says is possible then yes it can be tested. |
It should be possible to write a test confirming the new behaviour without changing any AppContext switches etc... |
Positive test added. |
@Wraith2 We also change AppContext switch in other tests to validate behavior before and after, would recommend the same here. |
Should I take that to mean that you wan me to add a negative test? |
Negative test added and positive test reworked to use the same way of ensuring that the test has the correct app context value set. I've used private reflection to set the internal field value and then restore it after each test, without doing this the per-process cache will prevent both tests succeeding in the same process. A simple lock prevents them running concurrently which is safe because they're very fast tests. |
Fixes #255
Changed RowVersion/Timestamp null behaviour for SqlDataReader so that it returns a DBNull value instead of an empty byte[]. An AppContext switch has been added to allow reverting to the previous (broken but kept that way for compatibility) behaviour, it's called
Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehaviour
and is cached on first check for the entire process.N.B. this is a breaking behavioural change.
/cc @dbrownems @bdebaere @mburbea