I'm using a PostgreSQL view as a data source. I'm trying to create a date range filter on one of the columns but it always returns no results.
The column is in the PostgreSQL "timestamp without time zone" format and is displayed in YYYY-MM-DD HH:MI:SS format when selected in the DB (e.g. "2024-06-29 22:30:00").
Why can't I filter on this date value? What format is it supposed to be in?
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
Filtering, sorting, and search may not work properly if you include:
Accent graves ( ` ) around the table name
JOIN functions
UNION functions
CONCAT functions
sub-queries
-
So, first you can check for accent graves around the table name, if you have this, remove it...
Then, see if you used CONCAT to create any column.
If so, go into this column setting, and disable it from "global search" in the Filtering tab.
-
If none of that helps,
you can try preparing a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.
If you need help with that, you can see our video, where we show an example of using View in our plugin.
I hope that helps.
But, if I understood, it seems you already tried with an SQL VIEW?
If that is the case, then see if you can possibly disable the server-side processing option in the table.
Basically, when the server-side is enabled, the wpDataTables will give the search results through the Query;
So, our Plugin sends the Query to the database.
If that Query is formatted as
"SELECT ...
FROM ...
WHERE... "
but after the "FROM" if it has any complex Query, as in your case, there can be errors with sorting/filtering/table search;
When the Server-Side is enabled, our plugin sends a more complex SQL Query which in this case is too complicated for our Parser to handle;
instead of when the server-side is disabled, in that case, it simply filters the data just by the values already seen in the column.
I hope that this helps to clarify everything.
To solve this particular issue, there can be multiple ways :
1. You can try to simplify your SQL Query as much as possible in order for our server-side processing to work;
2. Or try to make an SQL VIEW in your Database, then call it in our SQL Table like : SELECT * FROM ViewName
3. Or if you can make it work without server-side processing, if your data/number of rows of the table does not become too large, let's say above 4, 5, 6 thousand rows, and if the hosting server performs well,
you can 'get away' with disabling server-side on the table.
If your SQL query based tables are not bigger than 2.000 rows,
you can disable server-side on SQL tables, and it will work like it does for Excel tables. ( loads all rows regardless of pagination)
If you need to increase the row count while still having the "toggle" to disable server-side,
Please go to ../wp-content/plugins/wpdatatables/source/class.wpdatatable.php and around line 2176 you'll see this:
if (count($res_dataRows) > 2000) {
You can change that number to a value bigger than the number of rows in your table.
Same should be applied in ../wp-content/plugins/wpdatatables/source/class.wdtconfigcontroller.php on lines 53:
if (count($wpDataTable->getDataRows()) > 2000) {
And line 100:
if (count($wpDataTable->getDataRows()) > 2000) {
That will increase the server-side automatic limit.
I'm using a PostgreSQL view as a data source. I'm trying to create a date range filter on one of the columns but it always returns no results.
The column is in the PostgreSQL "timestamp without time zone" format and is displayed in YYYY-MM-DD HH:MI:SS format when selected in the DB (e.g. "2024-06-29 22:30:00").
Why can't I filter on this date value? What format is it supposed to be in?
Hi Adam,
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
As we pointed out on our Date Column Documentation :
So try that, if possible.
2. If not, we will provide additional details for general issues with filtering, if you have server-side processing enabled :
Our logic is based on a PHP SQL parser which has full support for the SQL dialect for the following statement types
SELECT, INSERT, UPDATE, DELETE, REPLACE, RENAME, SHOW, SET, DROP, CREATE INDEX, CREATE TABLE, EXPLAIN and DESCRIBE.
Some of them are disabled for security reasons.
Filtering, sorting, and search may not work properly if you include:
-
So, first you can check for accent graves around the table name, if you have this, remove it...
Then, see if you used CONCAT to create any column.
If so, go into this column setting, and disable it from "global search" in the Filtering tab.
-
If none of that helps,
you can try preparing a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.
If you need help with that, you can see our video, where we show an example of using View in our plugin.
I hope that helps.
But, if I understood, it seems you already tried with an SQL VIEW?
If that is the case, then see if you can possibly disable the server-side processing option in the table.
Basically, when the server-side is enabled, the wpDataTables will give the search results through the Query;
So, our Plugin sends the Query to the database.
If that Query is formatted as
"SELECT ...
FROM ...
WHERE... "
but after the "FROM" if it has any complex Query, as in your case, there can be errors with sorting/filtering/table search;
When the Server-Side is enabled, our plugin sends a more complex SQL Query which in this case is too complicated for our Parser to handle;
instead of when the server-side is disabled, in that case, it simply filters the data just by the values already seen in the column.
I hope that this helps to clarify everything.
To solve this particular issue, there can be multiple ways :
1. You can try to simplify your SQL Query as much as possible in order for our server-side processing to work;
2. Or try to make an SQL VIEW in your Database, then call it in our SQL Table like : SELECT * FROM ViewName
3. Or if you can make it work without server-side processing, if your data/number of rows of the table does not become too large, let's say above 4, 5, 6 thousand rows, and if the hosting server performs well,
you can 'get away' with disabling server-side on the table.
If your SQL query based tables are not bigger than 2.000 rows,
you can disable server-side on SQL tables, and it will work like it does for Excel tables. ( loads all rows regardless of pagination)
If you need to increase the row count while still having the "toggle" to disable server-side,
Please go to ../wp-content/plugins/wpdatatables/source/class.wpdatatable.php and around line 2176 you'll see this:
You can change that number to a value bigger than the number of rows in your table.
Same should be applied in ../wp-content/plugins/wpdatatables/source/class.wdtconfigcontroller.php on lines 53:
And line 100:
That will increase the server-side automatic limit.
I hope this helps.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables