mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Problem with direct compare in SELECT statement causing incompatibility with SQL Server database
Co-authored-by: Tomas Bilek
This commit is contained in:
parent
27c1c72912
commit
02827a6670
@ -96,11 +96,10 @@ class DBForeignKey extends DBInt
|
||||
// Remove distinct. Applying distinct shouldn't be required provided relations are not applied.
|
||||
$dataQuery->setDistinct(false);
|
||||
|
||||
$dataQuery->setSelect(['over_threshold' => 'count(*) > ' . (int) $threshold]);
|
||||
$dataQuery->setSelect(['over_threshold' => '(CASE WHEN count(*) > ' . (int)$threshold . ' THEN 1 ELSE 0 END)']);
|
||||
$result = $dataQuery->execute()->column('over_threshold');
|
||||
|
||||
// Checking for 't' supports PostgreSQL before silverstripe/postgresql@2.2
|
||||
$overThreshold = !empty($result) && ($result[0] === 't' || (int) $result[0] === 1);
|
||||
$overThreshold = !empty($result) && ((int) $result[0] === 1);
|
||||
|
||||
static::$foreignListCache[$hasOneClass] = [
|
||||
'overThreshold' => $overThreshold,
|
||||
|
Loading…
Reference in New Issue
Block a user