Commit 4e99dcb5 authored by guilhermeblanco's avatar guilhermeblanco

Fixes for test case in DQL

parent 0ad6aee3
......@@ -338,6 +338,51 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return in_array($fieldName, $this->_identifier);
}
/**
* Check if the field is unique
*
* @param string $fieldName The field name
* @return boolean TRUE if the field is unique, FALSE otherwise.
*/
public function isIdentifierComposite()
{
return ($this->_identifierType == Doctrine::IDENTIFIER_COMPOSITE);
}
/**
* Check if the field is unique
*
* @param string $fieldName The field name
* @return boolean TRUE if the field is unique, FALSE otherwise.
*/
public function isUniqueField($fieldName)
{
$mapping = $this->getColumnMapping($fieldName);
if ($mapping !== false) {
return isset($mapping['unique']) && $mapping['unique'] == true;
}
return false;
}
/**
* Check if the field is not null
*
* @param string $fieldName The field name
* @return boolean TRUE if the field is not null, FALSE otherwise.
*/
public function isNotNull($fieldName)
{
$mapping = $this->getColumnMapping($fieldName);
if ($mapping !== false) {
return isset($mapping['notnull']) && $mapping['notnull'] == true;
}
return false;
}
/**
* addIndex
*
......
......@@ -853,7 +853,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @return string
*/
public function modifyLimitQuery($query, $query, $limit = false, $offset = false, $isManip = false)
public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false)
{
return $query;
}
......
......@@ -79,7 +79,7 @@ class Doctrine_Query_Production_IndexBy extends Doctrine_Query_Production
// The INDEXBY field must be either the (primary && not part of composite pk) || (unique && notnull)
$columnMapping = $classMetadata->getColumnMapping($this->_fieldName);
if ( ! $classMetadata->isIdentifier($field) && ! $classMetadata->isUniqueField($field) && ! $classMetadata->isNotNull($field)) {
if ( ! $classMetadata->isIdentifier($this->_fieldName) && ! $classMetadata->isUniqueField($this->_fieldName) && ! $classMetadata->isNotNull($this->_fieldName)) {
$this->_parser->semanticalError(
"Field '" . $this->_fieldName . "' of component '" . $classMetadata->getClassName() .
"' must be unique and notnull to be used as index.",
......@@ -87,7 +87,7 @@ class Doctrine_Query_Production_IndexBy extends Doctrine_Query_Production
);
}
if ($classMetadata->isIdentifier($field) && $classMetadata->isIdentifierComposite()) {
if ($classMetadata->isIdentifier($this->_fieldName) && $classMetadata->isIdentifierComposite()) {
$this->_parser->semanticalError(
"Field '" . $this->_fieldName . "' of component '" . $classMetadata->getClassName() .
"' must be primary and not part of a composite primary key to be used as index.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment