mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
ENHANCEMENT: check for empty clause which will break the sql query
This commit is contained in:
parent
bef5b0ed05
commit
2aff1a9196
@ -1251,6 +1251,7 @@ class MSSQLDatabase extends SS_Database {
|
||||
// Create one query per each table, columns not used.
|
||||
foreach($tables as $tableName=>$columns){
|
||||
$join = $this->fullTextSearchMSSQL($tableName, $keywords);
|
||||
if (!$join) return new DataObjectSet(); // avoid "Null or empty full-text predicate"
|
||||
|
||||
// Check if we need to add ShowInSearch
|
||||
$where = null;
|
||||
@ -1322,6 +1323,8 @@ class MSSQLDatabase extends SS_Database {
|
||||
* @param $tableName specific - table name
|
||||
* @param $keywords string The search query
|
||||
* @param $fields array The list of field names to search on, or null to include all
|
||||
*
|
||||
* @returns null if keyword set is empty or the string with JOIN clause to be added to SQL query
|
||||
*/
|
||||
function fullTextSearchMSSQL($tableName, $keywords, $fields = null) {
|
||||
// Make sure we are getting an array of fields
|
||||
@ -1340,6 +1343,8 @@ class MSSQLDatabase extends SS_Database {
|
||||
$keywords = self::removeStopwords($keywords);
|
||||
$keywords = implode(' AND ', $keywords);
|
||||
|
||||
if (!$keywords || trim($keywords)=='') return null;
|
||||
|
||||
if ($fields) $fieldNames = '"' . implode('", "', $fields) . '"';
|
||||
else $fieldNames = "*";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user