Custom query having to add[0] to dynamic value to display it

Hi,
I have a custom MySQL query, to format a date field to Saturday, 6th November, 2023 for example.
There reason why I am using MySQL is that apparently its easier to get the day suffix (like th, st, nd etc)

After I create the custom query which has an alias ‘event_date_format’ it will have an empty value when I try to display it on the app side dynamic value picker.

Its only when I add a ‘set value’ on the server action and set a value from the mysql query output and I manually add “[0]” to the value. When I use the dynamic data picker in the Set Value Properties page on the server action it doesn’t include a [0] and it won’t display anything on the app page.

This will then display on the page.

Is there a reason for this?

!

1 Like

Custom queries return an array… So even if it returns only 1 record you have to pull it with [0]

2 Likes

Here @George, the user gave reproducible instructions even if this is not an intentional bug report

@cpuser in this case, the right option is using Database Single Query instead of Database Query, though it should’ve added [0] automatically anyway

1 Like

I had a production issue beacuse of this just yesterday.

Had to manually fix around 60 entries in the DB because of the missed zero index from custom query in picker.

Didn’t think much of it, but seeing the reports, it looks like a serious bug.

1 Like

Topic moved to bug reports, concerning the incorrect variable type identification

1 Like

Thanks for explaining @famousmag. The issue here as mentioned in my post is that Wappler isn’t generating the correct code and placing the [0], we are having to go in and edit it manually which defeats the purpose.

Thanks @Apple and @sid for flagging this and moving it to bugs.

Loving Wappler and how awesome it’s is and love the community support.

3 Likes

If you use a database single query, then there is no need for [0] as it is only one record. That is why it isn’t added.

@George I am using a Custom query and it only returns a single record, but I still have to manually enter the [0] for it to work.

I think that we all ask for the custom query to behave as a multiple records and not like a single record query by default…