corresponding datatypes need to be the same #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is achieved by returning nil types and nil *int pointers for nil *bool This is needed to prevent this error "ORA-01790: expression must have same datatype as corresponding expression"
Description
When passing in more than one say child and if the child uses pointers there is a potential for the datatypes to get mixed up if one of the child's pointers is nil and the other child's pointer is set. If this occurs the following error is returned.
"ORA-01790: expression must have same datatype as corresponding expression"
It appears a nil pointer check was added to the convertValue function which will return a nil if a pointer is nil. This causes the original type of the reference to get lost [ (*bool)(nil) was being converted to nil ]. From what I can tell this check was added because nil *bool types where not be persisted correctly. But looking at the convertValue function we don't want to return nil *bool as again the datatypes will get mixed up since the convertValue function is converting bools to int's so we want to return (*int)(nil) for nil *bools to keep the types the same.
The case I primarily ran into was with the usage of an *int in which one of the child's *int's were set and the other was a nil *int. This again caused the datatypes not to match in the corresponding expression. But the same goes for *bool's as well.
Fixes #114
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Included a corresponding test in pull request to demonstrate issue and verify fix. This test contains *int and *bool and verifies what is stored in the database after insertion. Two joining child records are created. One with nulls and the other with proper values to verify the datatypes are the same for both the child records.
Test Configuration:
Checklist: