mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUGFIX Workarounds for GroupSubsites::augmentSQL() so that it doesn't fail on databases other than MySQL like SQL Server
This commit is contained in:
parent
dce64a567f
commit
5984e62e45
@ -132,13 +132,15 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider {
|
||||
= \"Group\".\"ID\" AND \"Group_Subsites\".\"SubsiteID\" = $subsiteID");
|
||||
$query->where[] = "(\"Group_Subsites\".\"SubsiteID\" IS NOT NULL OR
|
||||
\"Group\".\"AccessAllSubsites\" = 1)";
|
||||
|
||||
if(!$query->groupby) $query->groupby[] = "\"Group\".\"ID\"";
|
||||
} else {
|
||||
$query->where[] = "\"Group\".\"AccessAllSubsites\" = 1";
|
||||
}
|
||||
}
|
||||
$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
|
||||
// WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server)
|
||||
if(!$query->select[0] == 'COUNT(*)') {
|
||||
$query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user