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

Bug: stored JSON value may be integer/float/string #58

Closed
strider2038 opened this issue Mar 8, 2020 · 5 comments · Fixed by #66
Closed

Bug: stored JSON value may be integer/float/string #58

strider2038 opened this issue Mar 8, 2020 · 5 comments · Fixed by #66
Assignees

Comments

@strider2038
Copy link
Contributor

We are storing variable type of data in JSONB field. It can be object, integer, float or string. So we have an issue with Jsonb and primitive types. I think array type must be removed from these methods.

https://github.com/martin-georgiev/postgresql-for-doctrine/blob/master/src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php#L45
https://github.com/martin-georgiev/postgresql-for-doctrine/blob/master/src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php#L33

@martin-georgiev
Copy link
Owner

Can you share an example with the actual outcome and the expected one?

@strider2038
Copy link
Contributor Author

JSON is not always objects or arrays. String or numeric values are valid JSON too. So this code

json_decode("\"string\"", true);

returns string result and leads to type exception here https://github.com/martin-georgiev/postgresql-for-doctrine/blob/master/src/MartinGeorgiev/Doctrine/DBAL/Types/JsonTransformer.php#L33.

@martin-georgiev
Copy link
Owner

@strider2038 do you mind confirming the changes in #66 will fix the use-case you have?

@strider2038
Copy link
Contributor Author

@strider2038 do you mind confirming the changes in #66 will fix the use-case you have?

Yes, this solves our issue. Thanks.

@martin-georgiev
Copy link
Owner

Cool, it is released in the last version published for Composer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants