# Custom\_fields simultaneous save with json becomes an array

**URL:** <https://meta.discourse.org/t/custom-fields-simultaneous-save-with-json-becomes-an-array/73647>\
**Category:** Bug\
**Created:** [8 Novembre 2017, 12:33am UTC](https://meta.discourse.org/t/custom-fields-simultaneous-save-with-json-becomes-an-array/73647 "2017-11-08T00:33:56Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)\
**Post date:** [8 Novembre 2017, 12:33am UTC](https://meta.discourse.org/t/custom-fields-simultaneous-save-with-json-becomes-an-array/73647/1 "2017-11-08T00:33:56Z")

</div>

Hi there, I think I hit what might be a bug in core, but I’m not sure what the desired functionality is.

I noticed this from working on the [discourse-push-notifications plugin](https://meta.discourse.org/t/discourse-push-notifications/46692) where the custom\_field is being set as an array sometimes. I suggested a [fix to merge the arrays](https://github.com/discourse/discourse-push-notifications/pull/15) and it was suggested that it could be a bug in core’s `custom_fields`.

I just investigated and [reproduced this behavior in a test](https://github.com/featheredtoast/discourse/commit/45cd73ff3714d7962f6bfae42029f24f9eec3b49). From what I can tell if two separate threads are saving simultaneously, it combines the data into an array as two separate values.

Is this the desired behavior? How should `custom_fields` behave when being saved like this?

---

_[View the full topic](https://meta.discourse.org/t/custom-fields-simultaneous-save-with-json-becomes-an-array/73647)._
