Ticket #1199 (closed defect: invalid)

Opened 21 months ago

Last modified 19 months ago

"symfony doctrine:data-dump" crashes on tables without "id" attribute

Reported by: birne Owned by: jwage
Priority: minor Milestone:
Component: sfDoctrinePlugin Version: 0.11.0
Severity: Keywords:
Cc: Has Test: no
Status: Pending Core Response Has Patch: no

Description

When dumping data fron an existing database (in my case PostgreSQL) into the fixtures.yml using the "symfony doctrine:data-dump" task, an error occurs when a table has no "id" attribute. The error message is an SQL error handed over from the database:

 ERROR: column c.id does not exist 
 LINE 1: SELECT c.id AS c__id, c.name AS c__name, ..

(the actual message can be different, my PostgreSQL throws german messages and I have translated it back myself. Also this error is from my memory as I have fixed all my tables already)

If every tables has to have an id attribute, please check if it is missing before the SQL query gets executed and throw an exception with a smarter message. If the id attributes are optional please have a look why the id attribute has been added to query a table that has none.

Change History

Changed 21 months ago by jwage

  • status changed from new to closed
  • resolution set to invalid

I suspect the issue here was that your table has a primary key defined which is not named id, but your Doctrine schema definition did not declare primary on the column for your existing database. So, if no column is defined as primary for Doctrine then a column named id is automatically added and set as primary and autoincrement.

Does your existing table have another column which is defined as primary and auto increment?

Changed 21 months ago by birne

  • status changed from closed to reopened
  • resolution invalid deleted

The table was the incarnation of a m-n relation containing only two foreign key fields. The primary key of that table consists of both fields. Again: this was not MySQL but PostgreSQL.

However it would help many people if the error message would contain more than SQL string that failed to run. It should at least contain the name of the table and something like jwage stated above.

Changed 20 months ago by jwage

  • status changed from reopened to closed
  • resolution set to invalid

Changed 19 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.