BUGFIX Don't try lazy loading fields when the record ID is set to something non-numeric, otherwise you'll get a SQL error.

This commit is contained in:
Sean Harvey 2012-05-15 17:18:04 +12:00
parent 0a6ec3d9c9
commit b1104dac25

View File

@ -1991,12 +1991,15 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
*
* @param tableClass Base table to load the values from. Others are joined as required.
*/
protected function loadLazyFields($tableClass = null) {
// Smarter way to work out the tableClass? Should the functionality in toMap and getField be moved into here?
if (!$tableClass) $tableClass = $this->ClassName;
$dataQuery = new DataQuery($tableClass);
// TableField sets the record ID to "new" on new row data, so don't try doing anything in that case
if(!is_numeric($this->record['ID'])) return false;
$dataQuery->where("\"$tableClass\".\"ID\" = {$this->record['ID']}")->limit(1);
$columns = array();