// Fix test on primary key in Collection

This commit is contained in:
rMalie
2011-12-27 17:33:14 +00:00
parent c9a4b789ff
commit f56a90fd5e
+11 -4
View File
@@ -415,7 +415,7 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
} }
/** /**
* Obtain some informations on a field (alias, name, type, etc.) * Obtain some information on a field (alias, name, type, etc.)
* *
* @param string $field Field name * @param string $field Field name
* @return array * @return array
@@ -433,14 +433,21 @@ class CollectionCore implements Iterator, ArrayAccess, Countable
} }
$fieldname = $split[$i]; $fieldname = $split[$i];
if (!isset($definition['fields'][$fieldname])) if ($fieldname == $definition['primary'])
throw new PrestashopException('Field '.$fieldname.' not found in class '.$this->classname); $type = ObjectMode::TYPE_INT;
else
{
if (!isset($definition['fields'][$fieldname]))
throw new PrestashopException('Field '.$fieldname.' not found in class '.$this->classname);
$type = $definition['fields'][$fieldname]['type'];
}
$this->fields[$field] = array( $this->fields[$field] = array(
'name' => $fieldname, 'name' => $fieldname,
'association' => $association, 'association' => $association,
'alias' => $this->generateAlias($association), 'alias' => $this->generateAlias($association),
'type' => $definition['fields'][$fieldname]['type'], 'type' => $type,
); );
} }
return $this->fields[$field]; return $this->fields[$field];