Skip to content

Conversation

@dmartin509
Copy link

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.

  • Bug fix (non-breaking change which fixes an issue)

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:

  • Database version: 23ai

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

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"
@oracle-contributor-agreement
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Dec 10, 2025
@ting-lan-wang
Copy link
Contributor

Hi @dmartin509, thank you for submitting the PR and for including a test to validate the result.
I’ve copied your changes into a new branch (tinglwan_pr-115), and everything looks good.
Let me know if you’d like to sign the OCA and proceed with your PR, or if you prefer that we continue with my branch instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants