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: ScalarType casting for Int values #3037

Merged
merged 3 commits into from
May 23, 2023
Merged

Conversation

BobaFetters
Copy link
Member

@BobaFetters BobaFetters commented May 22, 2023

Int32 and Int64 values were failing to cast to ScalarType because only Int conformed to ScalarType, adding code to the subscript functions of ObjectData and ListData to handle casting AnyHashable representations of Int32 and Int64 to just Int before the attempted casting to ScalarType

Closes #3034

`Int32` and `Int64` values were failing to cast to `ScalarType` because only `Int` conformed to `ScalarType`, adding conformance to both `Int32` and `Int64` to solve this
@netlify
Copy link

netlify bot commented May 22, 2023

Deploy Preview for apollo-ios-docs canceled.

Name Link
🔨 Latest commit 793a309
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docs/deploys/646bcd42422b870008268049

@BobaFetters BobaFetters marked this pull request as draft May 22, 2023 18:54
@BobaFetters
Copy link
Member Author

Going to refactor this to make sure we are always working with Int for consistency

Updating casting to happen in subscript methods of `ObjectData` and `ListData`
@BobaFetters BobaFetters changed the title Fixing ScalarType casting for Int values fix: ScalarType casting for Int values May 22, 2023
@BobaFetters BobaFetters marked this pull request as ready for review May 22, 2023 20:13
Copy link
Member

@calvincestari calvincestari left a comment

Choose a reason for hiding this comment

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

This looks good, thanks @BobaFetters. My only nitpick is updating the PR description to accurately reflect the diff.

@BobaFetters BobaFetters merged commit d67bef2 into main May 23, 2023
@BobaFetters BobaFetters deleted the fix/int-scalar-type-casting branch May 23, 2023 13:22
@calvincestari
Copy link
Member

@BobaFetters - I was thinking this morning that none of the execution sources perform JSON deserialization. We should probably add another test that actually uses JSONSerialization which would match the execution pattern that led us to this bug.

@BobaFetters
Copy link
Member Author

@calvincestari What kind of test are you thinking? One that checks that JSONSerialization returns an Int64 instead of an Int? Since we didn't change anything about JSONSerialization or _rawData to solve the issue I didn't think we would need extra tests there, but I am happy to add some more tests.

@calvincestari
Copy link
Member

calvincestari commented May 23, 2023

It wouldn't be about checking for an Int64 since that could change at any time. JSONSerializationFormat.deserialize specifically casts to AnyHashable. I think that coupled with whatever type JSONSerialization actually gives us is the path that we should maybe test.

@AnthonyMDev AnthonyMDev mentioned this pull request Jun 2, 2023
7 tasks
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.

NetworkResponseExecutionSource.DataTransformer Returns nil When It Should Not
2 participants