Have no idea how you will reproduce this on your end.
There are 2 tables which have these two columns - created_at & updated_at.
Both columns are of type varchar(30) and store a date time value with time zone like 2020-12-29T10:51:21+01:00.
I get the same output as above for both tables.
Can give remote to check the issue if you guys are unable to reproduce this at your end.
SELECT
COALESCE(MAX(updated_at),'2000-01-01T00:00:00') as 'last_updated',
COALESCE(MAX(created_at),'2000-01-01T00:00:00') as 'last_created'
from shop_products;
An alternative option is creating a View in the DB which becomes the source of the query - you wouldn’t even need it to be a custom query then as the View would do the MAX/ifnull bits
I have used Views numerous times when I need some complex query to be used in single/multiple/pages query step.
The purpose of custom query step is that I don’t have to create view for a single line of SQL which is not even complex.
Creating a view is an overkill and fixing the bug would be a better approach.
I have found a workaround for now in my server action & logic, but still want this to be fixed. Custom query should work for any query that works on the DB directly.
Agreed, fixing the native custom query would be ideal.
I think that the query builder, that allows queries to be written for many Database types, can’t cope for aggregate functions when no records at all exist. I bet if you saved the custom query and ran it anyway it would work (you could put a single temporary row in the table to test and then remove it once the schema had been pulled).
Unfortunately, for me its not returning any value when running in browser.
You trying this on MySQL?
Also, maybe try to put a random datetime instead of Not Found?
As explained in the original post, the field is a varchar(30). And the database server is NOT giving any error. The query is working fine when run on the server directly, but its Wappler that is unable to process it.
hello @sid
can you try adding limit 1 at the end of this query.
“Undefined offset” warning pops up when trying to access a nonexistent array element.
$ i [0] = 5;
echo $ i [1];
In the code above, only the zero element of the array has been defined and the value assigned, but when we want to access the element in the 1st index, we get an Undefined offset warning.