Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#DC-825 fixed

  • Loading branch information...
commit 41fe859eb94ed4658f3d3baf8676407840ce0ec1 1 parent 23a814e
Enrico Stahn authored estahn committed
View
12 lib/Doctrine/Import/Builder.php
@@ -530,6 +530,18 @@ public function buildColumns(array $columns)
$build = null;
foreach ($columns as $name => $column) {
+ // An alias cannot passed via column name and column alias definition
+ if (isset($column['name']) && stripos($column['name'], ' as ') && isset($column['alias'])) {
+ throw new Doctrine_Import_Exception(
+ sprintf('When using a column alias you cannot pass it via column name and column alias definition (column: %s).', $column['name'])
+ );
+ }
+
+ // Update column name if an alias is provided
+ if (isset($column['alias']) && !isset($column['name'])) {
+ $column['name'] = $name . ' as ' . $column['alias'];
+ }
+
$columnName = isset($column['name']) ? $column['name']:$name;
if ($manager->getAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE)) {
$e = explode(' as ', $columnName);
View
10 lib/Doctrine/Record/Generator.php
@@ -432,16 +432,6 @@ public function generateClassFromTable(Doctrine_Table $table)
$definition['tableName'] = $table->getTableName();
$definition['actAs'] = $table->getTemplates();
- // FIX: DC-825 This is probably not the right place to fix the issue.
- // Doctrine_Table::getColumns() should return the correct alias information.
- foreach ($definition['columns'] as $column => $def) {
- if ($column == $table->getFieldName($column)) {
- continue;
- }
-
- $definition['columns'][$column]['name'] = $column . ' as ' . $table->getFieldName($column);
- }
-
return $this->generateClass($definition);
}
View
1  lib/Doctrine/Table.php
@@ -2624,6 +2624,7 @@ public function getFieldValidators($fieldName)
|| $name == 'length'
|| $name == 'fixed'
|| $name == 'comment'
+ || $name == 'alias'
|| $name == 'extra') {
continue;
}
Please sign in to comment.
Something went wrong with that request. Please try again.