Code Duplication    Length = 26-26 lines in 2 locations

lib/Doctrine/ORM/Query/SqlWalker.php 2 locations

@@ 1381-1406 (lines=26) @@
1378
                $sqlParts = [];
1379
1380
                // Select all fields from the queried class
1381
                foreach ($class->fieldMappings as $fieldName => $mapping) {
1382
                    if ($partialFieldSet && ! in_array($fieldName, $partialFieldSet)) {
1383
                        continue;
1384
                    }
1385
1386
                    $tableName = (isset($mapping['inherited']))
1387
                        ? $this->em->getClassMetadata($mapping['inherited'])->getTableName()
1388
                        : $class->getTableName();
1389
1390
                    $sqlTableAlias    = $this->getSQLTableAlias($tableName, $dqlAlias);
1391
                    $columnAlias      = $this->getSQLColumnAlias($mapping['columnName']);
1392
                    $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
1393
1394
                    $col = $sqlTableAlias . '.' . $quotedColumnName;
1395
1396
                    if (isset($mapping['requireSQLConversion'])) {
1397
                        $type = Type::getType($mapping['type']);
1398
                        $col = $type->convertToPHPValueSQL($col, $this->platform);
1399
                    }
1400
1401
                    $sqlParts[] = $col . ' AS '. $columnAlias;
1402
1403
                    $this->scalarResultAliasMap[$resultAlias][] = $columnAlias;
1404
1405
                    $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $class->name);
1406
                }
1407
1408
                // Add any additional fields of subclasses (excluding inherited fields)
1409
                // 1) on Single Table Inheritance: always, since its marginal overhead
@@ 1413-1438 (lines=26) @@
1410
                // 2) on Class Table Inheritance only if partial objects are disallowed,
1411
                //    since it requires outer joining subtables.
1412
                if ($class->isInheritanceTypeSingleTable() || ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) {
1413
                    foreach ($class->subClasses as $subClassName) {
1414
                        $subClass      = $this->em->getClassMetadata($subClassName);
1415
                        $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias);
1416
1417
                        foreach ($subClass->fieldMappings as $fieldName => $mapping) {
1418
                            if (isset($mapping['inherited']) || ($partialFieldSet && !in_array($fieldName, $partialFieldSet))) {
1419
                                continue;
1420
                            }
1421
1422
                            $columnAlias      = $this->getSQLColumnAlias($mapping['columnName']);
1423
                            $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform);
1424
1425
                            $col = $sqlTableAlias . '.' . $quotedColumnName;
1426
1427
                            if (isset($mapping['requireSQLConversion'])) {
1428
                                $type = Type::getType($mapping['type']);
1429
                                $col = $type->convertToPHPValueSQL($col, $this->platform);
1430
                            }
1431
1432
                            $sqlParts[] = $col . ' AS ' . $columnAlias;
1433
1434
                            $this->scalarResultAliasMap[$resultAlias][] = $columnAlias;
1435
1436
                            $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName);
1437
                        }
1438
                    }
1439
                }
1440
1441
                $sql .= implode(', ', $sqlParts);