1
0
mirror of synced 2024-12-05 03:06:05 +03:00

make use of NamingStrategy for columns of embedded fields

This commit is contained in:
Johannes M. Schmitt 2013-11-01 21:44:57 +01:00
parent fd8b5bd045
commit 20fb8270dc
5 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,11 @@
# Upgrade to 2.5
## BC BREAK: NamingStrategy has a new method ``embeddedFieldToColumnName($propertyName, $embeddedColumnName)``
This method generates the column name for fields of embedded objects. If you implement your custom NamingStrategy, you
now also need to implement this new method.
# Upgrade to 2.4
## BC BREAK: Compatibility Bugfix in PersistentCollection#matching()

View File

@ -3094,7 +3094,7 @@ class ClassMetadataInfo implements ClassMetadata
$fieldMapping['declaredField'] = $property;
$fieldMapping['originalField'] = $fieldMapping['fieldName'];
$fieldMapping['fieldName'] = $property . "." . $fieldMapping['fieldName'];
$fieldMapping['columnName'] = $property . "_" . $fieldMapping['columnName'];
$fieldMapping['columnName'] = $this->namingStrategy->embeddedFieldToColumnName($property, $fieldMapping['columnName']);
$this->mapField($fieldMapping);
}

View File

@ -50,6 +50,14 @@ class DefaultNamingStrategy implements NamingStrategy
return $propertyName;
}
/**
* {@inheritdoc}
*/
public function embeddedFieldToColumnName($propertyName, $embeddedColumnName)
{
return $propertyName.ucfirst($embeddedColumnName);
}
/**
* {@inheritdoc}
*/

View File

@ -49,6 +49,16 @@ interface NamingStrategy
*/
function propertyToColumnName($propertyName, $className = null);
/**
* Returns a column name for an embedded property.
*
* @param string $propertyName
* @param string $embeddedColumnName
*
* @return string
*/
function embeddedFieldToColumnName($propertyName, $embeddedColumnName);
/**
* Returns the default reference column name.
*

View File

@ -87,6 +87,14 @@ class UnderscoreNamingStrategy implements NamingStrategy
return $this->underscore($propertyName);
}
/**
* {@inheritdoc}
*/
public function embeddedFieldToColumnName($propertyName, $embeddedColumnName)
{
return $this->underscore($propertyName).'_'.$embeddedColumnName;
}
/**
* {@inheritdoc}
*/