[2.0] Bug fixes
This commit is contained in:
parent
fb7adbbebb
commit
968ebb80c2
5 changed files with 125 additions and 50 deletions
|
@ -100,7 +100,7 @@ class IsolatedClassLoader
|
|||
return false;
|
||||
}
|
||||
|
||||
if (strpos($className, $this->_namespace) !== 0) {
|
||||
if (strpos($className, $this->_namespace.$this->_namespaceSeparator) !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -113,5 +113,4 @@ class IsolatedClassLoader
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -55,7 +55,7 @@ class YamlDriver extends AbstractFileDriver
|
|||
|
||||
if ($element['type'] == 'entity') {
|
||||
$metadata->setCustomRepositoryClass(
|
||||
isset($element['repositoryClass']) ? $xmlRoot['repositoryClass'] : null
|
||||
isset($element['repositoryClass']) ? $element['repositoryClass'] : null
|
||||
);
|
||||
} else if ($element['type'] == 'mappedSuperclass') {
|
||||
$metadata->isMappedSuperclass = true;
|
||||
|
@ -113,6 +113,28 @@ class YamlDriver extends AbstractFileDriver
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($element['id'])) {
|
||||
// Evaluate identifier settings
|
||||
foreach ($element['id'] as $name => $idElement) {
|
||||
$mapping = array(
|
||||
'id' => true,
|
||||
'fieldName' => $name,
|
||||
'type' => $idElement['type']
|
||||
);
|
||||
|
||||
if (isset($idElement['column'])) {
|
||||
$mapping['columnName'] = $idElement['column'];
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
|
||||
if (isset($idElement['generator'])) {
|
||||
$metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_'
|
||||
. strtoupper($idElement['generator']['strategy'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate fields
|
||||
if (isset($element['fields'])) {
|
||||
foreach ($element['fields'] as $name => $fieldMapping) {
|
||||
|
@ -138,13 +160,17 @@ class YamlDriver extends AbstractFileDriver
|
|||
}
|
||||
|
||||
if (isset($fieldMapping['unique'])) {
|
||||
$mapping['unique'] = (bool)$fieldMapping['unique'];
|
||||
$mapping['unique'] = (bool)$fieldMapping['unique'];
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['options'])) {
|
||||
$mapping['options'] = $fieldMapping['options'];
|
||||
}
|
||||
|
||||
|
||||
if (isset($fieldMapping['notnull'])) {
|
||||
$mapping['notnull'] = $fieldMapping['notnull'];
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['version']) && $fieldMapping['version']) {
|
||||
$metadata->setVersionMapping($mapping);
|
||||
}
|
||||
|
@ -153,28 +179,6 @@ class YamlDriver extends AbstractFileDriver
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($element['id'])) {
|
||||
// Evaluate identifier settings
|
||||
foreach ($element['id'] as $name => $idElement) {
|
||||
$mapping = array(
|
||||
'id' => true,
|
||||
'fieldName' => $name,
|
||||
'type' => $idElement['type']
|
||||
);
|
||||
|
||||
if (isset($idElement['column'])) {
|
||||
$mapping['columnName'] = $idElement['column'];
|
||||
}
|
||||
|
||||
$metadata->mapField($mapping);
|
||||
|
||||
if (isset($idElement['generator'])) {
|
||||
$metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_'
|
||||
. strtoupper($idElement['generator']['strategy'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate oneToOne relationships
|
||||
if (isset($element['oneToOne'])) {
|
||||
foreach ($element['oneToOne'] as $name => $oneToOneElement) {
|
||||
|
@ -338,6 +342,10 @@ class YamlDriver extends AbstractFileDriver
|
|||
'name' => $joinColumnElement['name'],
|
||||
'referencedColumnName' => $joinColumnElement['referencedColumnName']
|
||||
);
|
||||
|
||||
if (isset($joinColumnElement['fieldName'])) {
|
||||
$joinColumn['fieldName'] = (string) $joinColumnElement['fieldName'];
|
||||
}
|
||||
|
||||
if (isset($joinColumnElement['unique'])) {
|
||||
$joinColumn['unique'] = (bool) $joinColumnElement['unique'];
|
||||
|
|
|
@ -43,6 +43,16 @@ class From
|
|||
$this->_alias = $alias;
|
||||
}
|
||||
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->_from;
|
||||
}
|
||||
|
||||
public function getAlias()
|
||||
{
|
||||
return $this->_alias;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_from . ($this->_alias ? ' ' . $this->_alias : '');
|
||||
|
|
|
@ -55,7 +55,7 @@ class QueryBuilder
|
|||
*/
|
||||
private $_dqlParts = array(
|
||||
'select' => array(),
|
||||
'from' => null,
|
||||
'from' => array(),
|
||||
'join' => array(),
|
||||
'set' => array(),
|
||||
'where' => null,
|
||||
|
@ -192,10 +192,6 @@ class QueryBuilder
|
|||
return $this->_dql;
|
||||
}
|
||||
|
||||
if ( ! $this->_dqlParts['select'] || ! $this->_dqlParts['from']) {
|
||||
throw DoctrineException::incompleteQueryBuilder();
|
||||
}
|
||||
|
||||
$dql = '';
|
||||
|
||||
switch ($this->_type) {
|
||||
|
@ -238,6 +234,24 @@ class QueryBuilder
|
|||
return $this->_q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root alias for the query. This is the first entity alias involved
|
||||
* in the construction of the query
|
||||
*
|
||||
* [php]
|
||||
* $qb = $em->createQueryBuilder()
|
||||
* ->select('u')
|
||||
* ->from('User', 'u');
|
||||
*
|
||||
* echo $qb->getRootAlias(); // u
|
||||
*
|
||||
* @return string $rootAlias
|
||||
*/
|
||||
public function getRootAlias()
|
||||
{
|
||||
return $this->_dqlParts['from'][0]->getAlias();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a query parameter.
|
||||
*
|
||||
|
@ -373,7 +387,7 @@ class QueryBuilder
|
|||
}
|
||||
|
||||
/**
|
||||
* Add to the SELECT statement
|
||||
* Set the SELECT statement
|
||||
*
|
||||
* [php]
|
||||
* $qb = $em->createQueryBuilder()
|
||||
|
@ -393,6 +407,31 @@ class QueryBuilder
|
|||
return $this;
|
||||
}
|
||||
|
||||
return $this->add('select', new Expr\Select($selects), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to the SELECT statement
|
||||
*
|
||||
* [php]
|
||||
* $qb = $em->createQueryBuilder()
|
||||
* ->select('u')
|
||||
* ->addSelect('p')
|
||||
* ->from('User', 'u')
|
||||
* ->leftJoin('u.Phonenumbers', 'p');
|
||||
*
|
||||
* @param mixed $select String SELECT statement or SELECT Expr instance
|
||||
* @return QueryBuilder $qb
|
||||
*/
|
||||
public function addSelect($select = null)
|
||||
{
|
||||
$this->_type = self::SELECT;
|
||||
$selects = func_get_args();
|
||||
|
||||
if (empty($selects)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->add('select', new Expr\Select($selects), true);
|
||||
}
|
||||
|
||||
|
@ -458,7 +497,7 @@ class QueryBuilder
|
|||
*/
|
||||
public function from($from, $alias = null)
|
||||
{
|
||||
return $this->add('from', new Expr\From($from, $alias));
|
||||
return $this->add('from', new Expr\From($from, $alias), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -571,7 +610,7 @@ class QueryBuilder
|
|||
*/
|
||||
public function andWhere($where)
|
||||
{
|
||||
$where = $this->_getDqlQueryPart('where');
|
||||
$where = $this->getDqlPart('where');
|
||||
$args = func_get_args();
|
||||
|
||||
if ($where instanceof Expr\Andx) {
|
||||
|
@ -600,7 +639,7 @@ class QueryBuilder
|
|||
*/
|
||||
public function orWhere($where)
|
||||
{
|
||||
$where = $this->_getDqlQueryPart('where');
|
||||
$where = $this->getDqlPart('where');
|
||||
$args = func_get_args();
|
||||
|
||||
if ($where instanceof Expr\Orx) {
|
||||
|
@ -672,7 +711,7 @@ class QueryBuilder
|
|||
*/
|
||||
public function andHaving($having)
|
||||
{
|
||||
$having = $this->_getDqlQueryPart('having');
|
||||
$having = $this->getDqlPart('having');
|
||||
$args = func_get_args();
|
||||
|
||||
if ($having instanceof Expr\Andx) {
|
||||
|
@ -693,7 +732,7 @@ class QueryBuilder
|
|||
*/
|
||||
public function orHaving($having)
|
||||
{
|
||||
$having = $this->_getDqlQueryPart('having');
|
||||
$having = $this->getDqlPart('having');
|
||||
$args = func_get_args();
|
||||
|
||||
if ($having instanceof Expr\Orx) {
|
||||
|
@ -730,10 +769,31 @@ class QueryBuilder
|
|||
return $this->add('orderBy', new Expr\OrderBy($sort, $order), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a DQL part or parts by the part name
|
||||
*
|
||||
* @param string $queryPartName
|
||||
* @return mixed $queryPart
|
||||
*/
|
||||
public function getDqlPart($queryPartName)
|
||||
{
|
||||
return $this->_dqlParts[$queryPartName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full DQL parts array
|
||||
*
|
||||
* @return array $dqlParts
|
||||
*/
|
||||
public function getDqlParts()
|
||||
{
|
||||
return $this->_dqlParts;
|
||||
}
|
||||
|
||||
private function _getDqlForDelete()
|
||||
{
|
||||
return 'DELETE'
|
||||
. $this->_getReducedDqlQueryPart('from', array('pre' => ' '))
|
||||
. $this->_getReducedDqlQueryPart('from', array('pre' => ' ', 'separator' => ', '))
|
||||
. $this->_getReducedDqlQueryPart('where', array('pre' => ' WHERE '))
|
||||
. $this->_getReducedDqlQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
|
||||
}
|
||||
|
@ -741,7 +801,7 @@ class QueryBuilder
|
|||
private function _getDqlForUpdate()
|
||||
{
|
||||
return 'UPDATE'
|
||||
. $this->_getReducedDqlQueryPart('from', array('pre' => ' '))
|
||||
. $this->_getReducedDqlQueryPart('from', array('pre' => ' ', 'separator' => ', '))
|
||||
. $this->_getReducedDqlQueryPart('set', array('pre' => ' SET ', 'separator' => ', '))
|
||||
. $this->_getReducedDqlQueryPart('where', array('pre' => ' WHERE '))
|
||||
. $this->_getReducedDqlQueryPart('orderBy', array('pre' => ' ORDER BY ', 'separator' => ', '));
|
||||
|
@ -751,7 +811,7 @@ class QueryBuilder
|
|||
{
|
||||
return 'SELECT'
|
||||
. $this->_getReducedDqlQueryPart('select', array('pre' => ' ', 'separator' => ', '))
|
||||
. $this->_getReducedDqlQueryPart('from', array('pre' => ' FROM '))
|
||||
. $this->_getReducedDqlQueryPart('from', array('pre' => ' FROM ', 'separator' => ', '))
|
||||
. $this->_getReducedDqlQueryPart('join', array('pre' => ' ', 'separator' => ' '))
|
||||
. $this->_getReducedDqlQueryPart('where', array('pre' => ' WHERE '))
|
||||
. $this->_getReducedDqlQueryPart('groupBy', array('pre' => ' GROUP BY ', 'separator' => ', '))
|
||||
|
@ -761,7 +821,7 @@ class QueryBuilder
|
|||
|
||||
private function _getReducedDqlQueryPart($queryPartName, $options = array())
|
||||
{
|
||||
$queryPart = $this->_getDqlQueryPart($queryPartName);
|
||||
$queryPart = $this->getDqlPart($queryPartName);
|
||||
|
||||
if (empty($queryPart)) {
|
||||
return (isset($options['empty']) ? $options['empty'] : '');
|
||||
|
@ -772,13 +832,13 @@ class QueryBuilder
|
|||
. (isset($options['post']) ? $options['post'] : '');
|
||||
}
|
||||
|
||||
private function _getDqlQueryPart($queryPartName)
|
||||
{
|
||||
return $this->_dqlParts[$queryPartName];
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getDql();
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->_q = clone $this->_q;
|
||||
}
|
||||
}
|
|
@ -510,9 +510,7 @@ class SchemaTool
|
|||
// Column exists, check for changes
|
||||
$columnInfo = $column;
|
||||
$columnChanged = false;
|
||||
|
||||
echo $column['name'] . ' ';
|
||||
|
||||
|
||||
// 1. check for nullability change
|
||||
$columnInfo['notnull'] = ( ! isset($columnInfo['notnull']))
|
||||
? false : $columnInfo['notnull'];
|
||||
|
|
Loading…
Add table
Reference in a new issue