8000 Handle empty list keeping backward compatibility by afsalthaj · Pull Request #7891 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Handle empty list keeping backward compatibility #7891

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

Merged
merged 6 commits into from
Mar 5, 2023

Conversation

afsalthaj
Copy link
Contributor
@afsalthaj afsalthaj commented Mar 5, 2023

<nil> is another way (along with empty string) to encode empty list when the config is actually indexed. Usually only libraries like zio-config (or advanced users) would ever need to encode emptiness using as a String <nil>

Users who prefer to write flat-structure hardly end up doing this and can use "" as before. This implies, as test cases indicate, we keep all the existing behaviour of ConfigProvider as it is.

We can remove this pre-requisite in zio-3.x, where ConfigPath is the default behaviour

loop(prefix, config, split = true).map(Chunk(_))

case Right(chunk) =>
if (chunk.size == 1 && (chunk.headOption.contains("<nil>")))
Copy link
Contributor Author
@afsalthaj afsalthaj Mar 5, 2023

Choose a reason for hiding this comment

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

<nil> is another way (along with empty string) to encode empty list when the config is actually indexed. Usually only libraries like zio-config (or advanced users) would ever need to encode emptiness using as a String<nil>

Users who prefer to write flat-structure hardly end up doing this and can use "" as before. This implies, as test cases indicate, we keep all the existing behaviour of ConfigProvider as it is.

We can remove this pre-requisite in zio-3.x, where ConfigPath is the default behaviour

if (chunk.size == 1 && (chunk.headOption.contains("<nil>")))
ZIO.succeed(Chunk.empty).map(Chunk(_))
else loop(prefix, config, split = true).map(Chunk(_))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXME: A bit of clean up - just tested the functionality as of now and it works

@afsalthaj afsalthaj marked this pull request as ready for review March 5, 2023 12:48
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.

2 participants
0