Skip to content

Fix sample app: nested paths during decoding, supporting optional values#28

Merged
icanzilb merged 15 commits into
MarkCodable:mainfrom
DivineDominion:ctietze/fix-main-app
Sep 8, 2022
Merged

Fix sample app: nested paths during decoding, supporting optional values#28
icanzilb merged 15 commits into
MarkCodable:mainfrom
DivineDominion:ctietze/fix-main-app

Conversation

@DivineDominion

@DivineDominion DivineDominion commented Sep 7, 2022

Copy link
Copy Markdown
Contributor

Fixes #27

To be honest, I don't quite understand what's going on to make this happen, and what the implications are.

I'm fiddling around with tests to reproduce the problem and catch it there, too.

In the meantime, pointers and feedback would be welcome :)

@icanzilb

icanzilb commented Sep 7, 2022

Copy link
Copy Markdown
Collaborator

Thanks for catching and fixing this!

One of the PRs that got merged since yesterday must've broken the demo app. And I suspect is my PR here #22 but it's strange that none of the tests broke.

Give me a moment to double-check which code path that the previous PR removed was handling this use case just to make sure we're fixing this for good.

@icanzilb
icanzilb self-requested a review September 7, 2022 16:17
@icanzilb icanzilb self-assigned this Sep 7, 2022
@icanzilb icanzilb added the bug Something isn't working label Sep 7, 2022
@rizwankce

Copy link
Copy Markdown
Contributor

@icanzilb I just tested it out. It seems CodingPath is empty for price.price. We removed Collection type checks & nested containers with this 1845f68

I could be wrong.

@DivineDominion

Copy link
Copy Markdown
Contributor Author

Feel free to merge if this works for you 👍

@DivineDominion DivineDominion changed the title [WIP] Fix sample app Fix sample app Sep 7, 2022

@icanzilb icanzilb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks good and it fixes the bug, the only ask I have is to use the unit test to do few more checks

Comment thread Tests/MarkCodableTests/Utility/TestModels.swift
Comment thread Sources/MarkCodable/Decoder/MarkKeyedDecoding.swift
@DivineDominion DivineDominion changed the title Fix sample app Fix sample app: nested paths during decoding, supporting optional values Sep 8, 2022
@DivineDominion

Copy link
Copy Markdown
Contributor Author

@icanzilb PTAL

@icanzilb icanzilb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks good — it fixes a few things off the issues list and that's great!

I'll have to sit down and get a good overview of where we come short while encoding/decoding — e.g. I had no idea the *IfPresent methods were needed at all...

@icanzilb
icanzilb merged commit 5a122f0 into MarkCodable:main Sep 8, 2022
@DivineDominion
DivineDominion deleted the ctietze/fix-main-app branch September 8, 2022 17:21
@DivineDominion

Copy link
Copy Markdown
Contributor Author

@icanzilb Yeah I just noticed via caveman debugging that none of the others were ever called. I do wonder what the default protocol implementations do -- they don't use the generic encoder/decoder, that's for sure 🤔

I believe the next best thing is to duplicate the single optional string test case for all primitive values, and group that in a separate test case file for overview. Or maybe generate the code via Sourcery, if that's you thing :) But to be 100% certain what happens when, we need to cover more permutations, which is quite annoying.

I envy Apple and the fact that they don't test :-----)

@icanzilb

icanzilb commented Sep 8, 2022

Copy link
Copy Markdown
Collaborator

@DivineDominion that's not entirely true, there's plenty of tests and I do intend to "snatch" them #20

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example app does not run step 2 or later

3 participants