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

Optional strings should return nil, not empty string #53

Conversation

schneiderderek
Copy link
Contributor

Fixes an issue for xpaths using optional strings where the returned
value would be an empty string ("") instead of nil.

Fixes an issue for xpaths using optional strings where the returned
value would be an empty string ("") instead of nil.
@doughsay
Copy link

Hey there, I need this fix for a project I'm trying to use sweet_xml for. Any reason we can't merge this?

@stevedomin
Copy link

Hi! Any chance to get this merged?

@nathany-copia
Copy link

Any chance of getting this (or similar) in?

Right now strings don't behave as described by the README:

"If you use the optional modifier o together with a soft cast modifier (uppercase), then the value is set to nil"

@Shakadak
Copy link
Member

Hi, no:

  • This is not backward compatible: there are valid cases resulting in an empty string or list
  • This bypasses the casting mechanism instead of correcting it, which is why the added test that should not convert to anything still converts to nil
  • The casting mechanism is ambiguous because of how xmerl_xpath is currently used. It seems something can be done on that front, but it is much more involved than the change in this PR, and it would mean creating a new API (probably an entirely new lib) because of our backward compatibility requirement.
  • The transform_fun allows to do the same as this PR

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.

5 participants