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

Hashes with type&value keys returned by the helpers get immediately unpacked #11

Closed
ehuelsmann opened this issue Nov 20, 2016 · 0 comments

Comments

@ehuelsmann
Copy link
Contributor

The helper returns a hash containing (in case of ByteString) two keys: type and value. That return value is recorded here:

https://github.com/ledgersmb/PGObject/blob/master/lib/PGObject.pm#L303

Then, the same mapper goes on to:

https://github.com/ledgersmb/PGObject/blob/master/lib/PGObject.pm#L306

Here, the hash gets unpacked and the $arg->{value} part of the ByteString::to_db() method gets assigned to $arg (note that there's no reference to the returned hash anymore at this point).

Then, execution continues to binding the parameters. At this point, you want to have the return value from ByteString's to_db() available, so we can use the 'type' key here:

https://github.com/ledgersmb/PGObject/blob/master/lib/PGObject.pm#L340

to bind to a pg_type. However, because we unpacked the returned hash in L306, there no longer is a hash and we pass on to the second half of the if statement, dropping everything after the first NULL (\0) character.

ehuelsmann added a commit that referenced this issue Nov 20, 2016
* Fix #11: don't discard mapping hints from helpers
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

No branches or pull requests

1 participant