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

Jsonb type limited convert #161

Open
halfik opened this issue Oct 17, 2023 · 4 comments
Open

Jsonb type limited convert #161

halfik opened this issue Oct 17, 2023 · 4 comments

Comments

@halfik
Copy link

halfik commented Oct 17, 2023

JsonB type has now limitation on convertToPhpValue function. You can't convert to some custom php classes now like this:

public function convertToPHPValue($value, AbstractPlatform $platform): Currency

Any reason behind limiting convert to only simple php types?

@martin-georgiev
Copy link
Owner

I don't fully understand your idea. Can you please elaborate with more details?

@halfik
Copy link
Author

halfik commented Jan 12, 2024

https://github.com/martin-georgiev/postgresql-for-doctrine/blob/main/src/MartinGeorgiev/Doctrine/DBAL/Types/Jsonb.php

You limited types int this when it convertio into. It can convert any object itno jsonb, but you won't be able to recreate same object from jsob.

So u can conber instance of my CustomClass but i can't get it back since im limited to simple types only.

@martin-georgiev
Copy link
Owner

Can you add some code samples, please? The phpdoc for Jsonb clearly says that only array|bool|float|int|string|null data types are supported.

@halfik
Copy link
Author

halfik commented Jan 17, 2024

Yes and that is an issue. You can conver instance of CustomClass into jsonb on db, but u cant conver from db to CustomClass bc you can get only array|bool|float|int|string|null

convertToDatabaseValue allows to convert any object u want into db string
convertToPHPValue won't allow to recreate it

And its a big issue in DDD aproach where u have lot of domain defined custom objects you want to store as jsonb.

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

2 participants