Skip to content

rtwent/embedObjectBug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

embedObjectBug

Embed object bug when using jsonb on postgresql

In the entity App\Entity\CachedGeo we store translations of the regions in postgres jsonb format, e.g. {"ua": {"name": "some name", "declination": "in name"}}.

All methods work perfectly, but method "patch" gives strange behaviour. While updating embedded json (by patch method) - nothing happens with embedded json.

curl -X 'PATCH' \ 'http://localhost:8089/cached_geos/1ebf12e9-ff5d-6564-ba92-8d5ceeb93c2a' \ -H 'accept: application/ld+json' \ -H 'Content-Type: application/merge-patch+json' \ -d '{ "i18n": { "ru": { "name": "ru", "declination": "in ru" }, "ua": { "name": "ua", "declination": "in ua" } }, "lft": 2, "rgt": 3 }'

Expected behaviour is changing the value of i18n field in database - but got old value.

After digging, I've found solution, but according to bugs api-platform/core#4293 and api-platform/core#1534 it is hard for me to understand: am I on the right way or I have to read manuals more scrupulously.

After deserialization process - I had everything as expected, but while persisting - strange doctrine behaviour happens. Please look at App\DataPersister\CachedGeoDataPersister comment at line 52 (

// here $originalData['i18n'] is equals to data that was PATCHed by user
). Original entity data in the UnitOfWork is same, that came from user during "Patch" request.

Is it expected behaviour?

About

Embed object bug when using jsonb on postgresql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages