原则:具有 column_aggregation 继承的模型在 SQL 中出现两次
有人注意到这一点吗?
每当模型使用column_aggregation(继承)时,schema.sql 有 2 个 CREATE TABLE 命令,一个创建基本表,另一个(除了字段)在继承列上添加索引。
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;
请注意包含 INDEX Prop_property_nature_idx ( property_nature) 在第二个语句中
如果其他人也面临这个问题,我将记录一个错误。谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己刚刚遇到过这个。看起来
doctrine:build-sql
有问题。我在调查时发现的最疯狂的事情之一是,
doctrine:insert-sql
甚至不使用 schema.sql。它根据模型定义动态生成并运行 SQL。看起来这是一个已知的错误,不会在 Doctrine 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: