ENHANCEMENT: Improve TableListField query generation, so that it checks whether the DataObject has a database field, rather than just checking to see if it *doesn't* have a field or method.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78153 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-05-31 11:07:28 +00:00
parent f8fff9709d
commit 30517119d4

View File

@ -458,13 +458,12 @@ JS
$query->select[] = "{$baseClass}.ClassName AS \"RecordClassName\"";
} else {
$query = singleton($this->sourceClass)->extendedSQL($this->sourceFilter(), $this->sourceSort, null, $this->sourceJoin);
// Add more selected fields if they are from joined table.
$SNG = singleton($this->sourceClass);
foreach($this->FieldList() as $k=>$title){
if(!$SNG->hasField($k) && !$SNG->hasMethod('get' . $k) && !$SNG->hasMethod($k) && !strpos($k, "."))
foreach($this->FieldList() as $k => $title) {
if(!strpos($k, '.') && singleton($this->sourceClass)->hasDatabaseField($k)) {
$query->select[] = "\"$k\"";
}
}
}