I have a view which when called from regular Query, works fine. But, when the same query is called from Custom query, the results are weird.
The reason why I need to call it from Custom Query is that I need to add to this query. But since it did not work here (although it worked perfectly in phpMyAdmin), I tested various things and finally found this.
Actual behavior
This query works fine and returns correct number of rows:
Timezone issue, how?
I am running the same query on the same UI.
Only difference is one time the date comes from param and other its hardcoded.
Definitely not a timezone issue.
The issue is with the parameters. Please see the screenshots carefully.
Its the same date - ‘2019-11-30’ for which result is 2 rows when using parameter, and 76 when hardcoded.
Oh. Sorry.
The response is crashing on starting 2 entries/rows only. So I am just getting two records, both with date 2019-11-01 (which is the start date)
In the full result set, there are more records on more dates.
The query works fine in phpMyAdmin and Wappler’s regular database query step.
Its the custom query that is causing this issue. So probably that is comparing strings instead of dates… if that is actually the issue.
Damn. I did not notice when the debug option got added to custom query.
So from debug, it turns out the first param is getting replicated for all.
This is how the debug output looks like:
"custom1": { "query": "select * from vw_bill where Date between ? and ? and Sno = ?;", "params": [ { "name": ":P1", "value": "2019-11-01 00:00:00", "test": "2019-11-01" }, { "name": ":P1", "value": "2019-11-01 00:00:00", "test": "2019-11-01" }, { "name": ":P1", "value": "2019-11-01 00:00:00", "test": "2019-11-01" } ] }
I added in a third variable just to test. In the UI I have P1, P2 & P3. But debug shows only P1 for all three cases.