Doctrine:具有column_aggregation继承的模型在SQL中出现两次 [英] Doctrine: Models with column_aggregation inheritance appear twice in SQL

查看:113
本文介绍了Doctrine:具有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)在第二个陈述中



如果有人面对这个,我会记录一个错误。谢谢

解决方案

我刚刚遇到这个问题。看起来像 doctrine:build-sql 是错误的。



在调查这个时我发现的一个疯狂的事情是 doctrine:insert-sql 甚至不使用schema.sql 。它基于模型定义动态生成和运行SQL。



看起来这是一个已知的错误,在Doctrine 1中将不会被修复:




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

解决方案

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:

这篇关于Doctrine:具有column_aggregation继承的模型在SQL中出现两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆