mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
BUG FIX: actual available classes of a page now returned
This commit is contained in:
parent
7516f0bad5
commit
7ea01e108e
@ -1119,9 +1119,31 @@ class PostgreSQLDatabase extends SS_Database {
|
|||||||
* @todo Make a proper implementation
|
* @todo Make a proper implementation
|
||||||
*/
|
*/
|
||||||
function enumValuesForField($tableName, $fieldName) {
|
function enumValuesForField($tableName, $fieldName) {
|
||||||
return array('SiteTree','Page');
|
//return array('SiteTree','Page');
|
||||||
|
$constraints=$this->constraintExists("{$tableName}_{$fieldName}_check");
|
||||||
|
$classes=Array();
|
||||||
|
if($constraints)
|
||||||
|
$classes=$this->EnumValuesFromConstraint($constraints['pg_get_constraintdef']);
|
||||||
|
|
||||||
|
return $classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual enum fields from the constraint value:
|
||||||
|
*/
|
||||||
|
private function EnumValuesFromConstraint($constraint){
|
||||||
|
$constraint=substr($constraint, strpos($constraint, 'ANY (ARRAY[')+11);
|
||||||
|
$constraint=substr($constraint, 0, -11);
|
||||||
|
$constraints=Array();
|
||||||
|
$segments=explode(',', $constraint);
|
||||||
|
foreach($segments as $this_segment){
|
||||||
|
$bits=preg_split('/ *:: */', $this_segment);
|
||||||
|
array_unshift($constraints, trim($bits[0], " '"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $constraints;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Because NOW() doesn't always work...
|
* Because NOW() doesn't always work...
|
||||||
* MSSQL, I'm looking at you
|
* MSSQL, I'm looking at you
|
||||||
|
Loading…
Reference in New Issue
Block a user