easydb icon indicating copy to clipboard operation
easydb copied to clipboard

insertGet return null if MySQL table contains JSON type field

Open RGBvision opened this issue 3 years ago • 3 comments

insertGet('table', ['text_field' => 'text', 'json_field' => json_encode([1,2,3])], 'id') will not return 'id'

RGBvision avatar Dec 08 '22 18:12 RGBvision

Does your table have an id field? The JSON is likely a red herring.

paragonie-security avatar Dec 15 '22 09:12 paragonie-security

Does your table have an id field? The JSON is likely a red herring.

Yep. id - INT (autoincrement) and primary key. insertGet work as expected if I change JSON data type to TEXT. But in this case I can't use benefits of JSON fields.

RGBvision avatar Dec 15 '22 10:12 RGBvision

Oh, interesting.

https://github.com/paragonie/easydb/blob/79760589dbc2d77c83825dcd565f070dabfa23e2/src/EasyDB.php#L691-L709

This logic might be invalid for a JSON field.

paragonie-security avatar Dec 20 '22 05:12 paragonie-security