Doctrine: Models with column_aggregation inheritance appear twice in SQL

亡梦爱人 提交于 2019-12-24 15:36:17

问题


Has anyone noticed this?

Whenever a model uses column_aggregation (inheritance), the schema.sql has 2 CREATE TABLE commands, one creates the basic table, and the other (apart from fields) adds an index on the inheritence column

CREATE TABLE Prop (id INT AUTO_INCREMENT, opt_property_type SMALLINT UNSIGNED DEFAULT 251 NOT NULL, property_nature VARCHAR(255), INDEX opt_property_type_idx (opt_property_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

CREATE TABLE Prop (id INT AUTO_INCREMENT, opt_property_type SMALLINT UNSIGNED DEFAULT 251 NOT NULL, property_nature VARCHAR(255), INDEX Prop_property_nature_idx (property_nature), INDEX opt_property_type_idx (opt_property_type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

Note the inclusion of INDEX Prop_property_nature_idx (property_nature) in the second statement

If anyone else is facing this, I will log a bug. Thanks


回答1:


I just came across this myself. It seems like doctrine:build-sql is buggy.

One of the crazier things I discovered while investigating this is that doctrine:insert-sql doesn't even use schema.sql. It dynamically generates and runs the SQL based on the model definitions.

Looks like this is a known bug and won't be fixed in Doctrine 1:

  • http://www.doctrine-project.org/jira/browse/DC-123
  • http://www.doctrine-project.org/jira/browse/DC-536


来源:https://stackoverflow.com/questions/6087413/doctrine-models-with-column-aggregation-inheritance-appear-twice-in-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!