Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed this issue where the _getInsertColumnList() method was return dupl... #390

Closed
wants to merge 1 commit into from

4 participants

Marc Easen Don't Add Me To Your Organization a.k.a The Travis Bot Benjamin Eberlei Fabio B. Silva
Marc Easen
Easen commented July 05, 2012

...icated columns if the columns are quotes and the JoinColumns were not

Fixed this issue where the _getInsertColumnList() method was return d…
…uplicated columns if the columns are quotes and the JoinColumns were not
4637e5b
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged 4637e5b into cc46135).

Benjamin Eberlei
Owner

This looks like a fix for the symptom, not the root cause.

Fabio B. Silva
Owner

:-1: doesn't looks like a good way to fix.

@Easen, why do you need to quoted columns and unquoted join column ?
For sure duplicated columns is a problem, but your use case does not make sense for me..

Marc Easen
Easen commented July 15, 2012

The reason for quoted columns and not quoted join columns is because that approach doesn't work when you come to update the schema of the DB. In this case when Doctrine queries MySQL for the current foreign keys, and the columns that are returned are not quoted. So when the diff is created Doctrine tries to remove these columns and recreates them, but quoted. I can appreciate that this is in fact the bug which I should be reporting.

Because of this undesired side effect I chose to quote columns and not join columns, but then another issue arose Doctrine comes to create an insert/update statement the list of columns that are produces are duplicated, the columns are quoted and appended are the join columns unquoted, for example.

INSERT INTO foo (id, barId, barId);

Just a little of background info:

The reason for these quotes it that I design my DB in MySQL Workbench and then export this into Doctrine entities. So I need a one size fits all solution for all database designs, so my approach is to quote all columns. At the end of the day Doctrine should have a problem with this.

Fabio B. Silva
Owner

Hi @Easen

Sorry, we couldn't accept this patch
The real problem here is the schema update that you describe

Could you create a new ticket given more details about the schema update problem ?

Thanks

Fabio B. Silva FabioBatSilva closed this August 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 05, 2012
Fixed this issue where the _getInsertColumnList() method was return d…
…uplicated columns if the columns are quotes and the JoinColumns were not
4637e5b
This page is out of date. Refresh to see the latest.
9  lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
@@ -1248,6 +1248,15 @@ protected function _getInsertColumnList()
1248 1248
             }
1249 1249
         }
1250 1250
 
  1251
+        foreach($columns as &$column) {
  1252
+            if ($column[0] !== $this->_platform->getIdentifierQuoteCharacter()) {
  1253
+                $quotedColumn = $this->_platform->quoteSingleIdentifier($column);
  1254
+                if (in_array($quotedColumn, $columns)) {
  1255
+                    $column = $quotedColumn;
  1256
+                }
  1257
+            }
  1258
+        }
  1259
+
1251 1260
         return $columns;
1252 1261
     }
1253 1262
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.