Help with Storing Array as [1, 8, 9] Instead of ["1", "8", "9"] in Wappler

Hi everyone,

I'm encountering an issue with storing an array in MySQL using Wappler, and I'm hoping someone can help me figure out how to store the array as [1, 8, 9] instead of ["1", "8", "9"].

In my first project, I have an input field and I'm using a variable $_POST.tags (classified as text, getting Tagify values). I then have a set value valarray = $_POST.tags.split(','), and finally, I have a database insert with a JSON field where I insert {{valarray}}. This setup works perfectly, and it stores the values as [1, 8, 9].

However, when I replicated the same setup on a different website, it inserts the values as ["1", "8", "9"]. Since everything seems to be identical between the two projects, I'm unsure what could be causing this difference.

Can someone please provide suggestions or insights on how I can ensure the values are stored as [1, 8, 9]?

Screenshot 2024-08-05 alle 13.14.00

Screenshot 2024-08-05 alle 13.14.34

The field in MySql is a json field

Thank you in advance for your help!

Split is used to split a string into an array. If you are using tagify it sends an array directly and you don't need any .split() used.

Yes but problem persist to save [9,10] or [“9”,"10"].
what can change ?

Tagify sends the values in the array as strings. Can you explain in more details why is that an issue for you / where does it cause any troubles?

In the previous version of the site, which was an MVP, I used the Tagify component and the server connect saved the data as an array of numbers, like this: [1, 9, 89, 245]. However, when developing the production version of the website, the same server connect (created exactly as the first one) saves the array as text, like this: ["1", "67"].

I want to understand first why there is a difference in the data formats between the two versions and then how this might affect queries where JSON_CONTAINS is used.

If you says that I can go with IDs saved in the array as a text, I can go..

How exactly are you storing the values then?

How was this done - how do you submit the values and how do you process and save them?

I don't think anything has changed in the tagify component - it always uses strings.

Now I checked in the old application.. it started to write as text
Sincerely I don't know hat can be changed

Screenshot 2024-08-05 alle 15.45.25

What do you mean?
Can you show your server action steps?

In the old version of the site, the server connect saved the array elements as numbers. However, in the current version, it saves them as text. I don't know if I upgraded something..

This is the MySQL table, as you can see it changed the way to save the arrays

Screenshot 2024-08-05 alle 16.52.01

This as the query I was using. the Var1[0] contains the value of the tag.

in the new website I'm using this query:

'''select news_id, news_keywords from news where JSON_CONTAINS(news_keywords, ?, '$')

but it doesnt works with "14", while it works if I modify in the MySQL field ["14"] with [14]

Screenshot 2024-08-05 alle 17.02.43

I use JSON_CONTAINS with the following:
image

Hope it helps