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.
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.
Sorry, I commented on an incorrect post.
I completely understand the reason for needing to add the index. I don't thing a single custom query would make much sense, given low use case. But not a bad idea.
The problem I actually have right now, is that it does not actually add this index, when selecting from data picker.
I think there is another post in the community about it. Its a bug.
I remember, before single queries, dealing with this all the time.
The easiest way was to use a repeat action (even though there is only 1 record) then the value can be referenced without the [0]
I also think using a repeat action is the safest way to handle the database results. What happens when it didn't return 1 result, you can add LIMIT 1 to the query to prevent more records, but what when there is 0 results? With a repeat action it will just skip when there are no records and it also handles single or multiple records nicely.
Yeah.. I see and my apologies for that statement!
I was obviously talking for the time I joined Wappler community...
Well, now we have 4 type of queries:
As I see it the only one of them restricted with limit 1 is the first one, the Single query.
All the others are fetching all the records matching the search criteria.
So I suppose we talk about a fifth type of query... A "single custom query"
It seems there is some confusion here. @George This post is about custom query NOT adding [0] index when selecting from data picker.
Which it has been doing since the beginning - irrespective of whether the output of custom query is one or multiple rows.
But in Nov 23, this broke with some update, and until 6.4.1, which I am on right now, its still a problem.
The custom query steps requires [0] to be added if someone tries to select it directly in action picker.
Hope this makes the problem here, clearer.
CC: @patrick
An additional single custom query would be welcomed, but issue with existing custom query needs to be fixed before that.
Because the database server returns an "Array" of rows, even if it's just one row. Mutating the data structure to a single record would require an additional option to perform such to be implemented.