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

fix(go/adbc/driver/internal/driverbase): proper unmarshalling for ConstraintColumnNames #2285

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

zeroshade
Copy link
Member

Fixes #2278

The current UnmarshalJSON function for requiredList ended up unmarshalling into a copy of the underlying slice rather than using the actual slice, so the data wasn't being propagated appropriately. This fixes the UnmarshalJSON function to handle the scenario appropriately.

@github-actions github-actions bot modified the milestone: ADBC Libraries 15 Oct 28, 2024
@zeroshade
Copy link
Member Author

CC @davidhcoe Can you confirm that this fixes the issue reported?

@github-actions github-actions bot added this to the ADBC Libraries 15 milestone Oct 28, 2024
@davidhcoe
Copy link
Contributor

davidhcoe commented Oct 29, 2024

This doesn't work for me. I put together a sample to test with based on the result I get from Snowflake:
sf_results.json

func (suite *SnowflakeTests) TestJsonUnmarshal() {
   jsonFile, err := os.Open("sf_results.json")
   if err != nil {
   	log.Fatal("Failed to open file:", err)
   }
   defer jsonFile.Close()

   byteValue, err := ioutil.ReadAll(jsonFile)

   var getObjectsCatalog driverbase.GetObjectsInfo
   if err := json.Unmarshal(byteValue, &getObjectsCatalog); err != nil {
   	log.Fatal("Failed to parse JSON:", err)
   }

   for i, sch := range getObjectsCatalog.CatalogDbSchemas {
   	for j, tab := range sch.DbSchemaTables {
   		for k, con := range tab.TableConstraints {
   			for l, _ := range con.ConstraintColumnNames {
   				fmt.Println(getObjectsCatalog.CatalogDbSchemas[i].DbSchemaTables[j].TableConstraints[k].ConstraintColumnNames[l])
   			}
   		}
   	}
   }
}

@zeroshade
Copy link
Member Author

@davidhcoe I've updated the PR and added a test based on your example. Can you confirm it works for you?

@davidhcoe
Copy link
Contributor

Yes -- it works for me now. Thank you.

Copy link
Member

@joellubi joellubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch with the non-pointer receiver, thanks!

@zeroshade zeroshade merged commit f6a8861 into apache:main Oct 30, 2024
40 checks passed
@zeroshade zeroshade deleted the fix-constraint-decoding branch October 30, 2024 14:23
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.

snowflake: driver is not returning ConstraintColumnNames, ConstraintColumnUsage
4 participants