Customer report data store: fix SQL when where clauses are empty.

This commit is contained in:
Jeff Stieler 2018-12-20 15:31:20 -07:00
parent 1832450fd1
commit 04a30e668b
1 changed files with 4 additions and 2 deletions

View File

@ -144,7 +144,7 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store
}
if ( $where_time_clauses ) {
$sql_query['where_time_clause'] = implode( " {$match_operator} ", $where_time_clauses );
$sql_query['where_time_clause'] = ' AND ' . implode( " {$match_operator} ", $where_time_clauses );
}
return $sql_query;
@ -214,7 +214,7 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store
}
if ( $where_clauses ) {
$preceding_match = empty( $sql_query_params['where_time_clause'] ) ? '' : " {$match_operator} ";
$preceding_match = empty( $sql_query_params['where_time_clause'] ) ? ' AND ' : " {$match_operator} ";
$sql_query_params['where_clause'] = $preceding_match . implode( " {$match_operator} ", $where_clauses );
}
@ -262,6 +262,7 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store
{$table_name}
{$sql_query_params['from_clause']}
WHERE
1=1
{$sql_query_params['where_time_clause']}
{$sql_query_params['where_clause']}
"
@ -279,6 +280,7 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store
{$table_name}
{$sql_query_params['from_clause']}
WHERE
1=1
{$sql_query_params['where_time_clause']}
{$sql_query_params['where_clause']}
GROUP BY