简体   繁体   English

为什么复合主键中的列顺序对Doctrine至关重要?

[英]Why does the column order in a composite primary key matter to Doctrine?

I'm trying to set up a project using Doctrine 2.3.2 on a database-first implementation. 我试图在数据库优先实现上使用Doctrine 2.3.2建立一个项目。 after generating the xml and the mappings, then calling orm:validate-schema it shows me that the mapping is right but the database validation fails. 生成xml和映射之后,然后调用orm:validate-schema,它向我显示映射正确,但是数据库验证失败。 In using the schema tool to find out where my issues I'm finding 2 issues are repeating over and over: 在使用架构工具找出问题所在时,我发现有2个问题反复出现:

  1. change all my varchars that aren't already at 255 to varchar(255) 将我所有尚未在255的varchar更改为varchar(255)
  2. drop my primary key with for example the columns (A, B, C) and then create a new primary key with the same columns in a different order (B, A, C) 删除例如带有列(A,B,C)的主键,然后使用相同的列以不同的顺序(B,A,C)创建一个新的主键

Both of these things seem meaningless to change. 这两件事似乎都无济于事。 Why would Doctrine force me to change my schema in ways that seem meaningless? 为什么教义会强迫我以似乎毫无意义的方式更改自己的模式?

The solution to both of these without changing the database schema is: 这两种解决方案都无需更改数据库架构即可:

  1. the convert-mapping doesn't appear to add the length property to the id field - add it to the xml 转换映射似乎未将length属性添加到id字段-将其添加到xml
  2. This appears to be caused by a difference between the order of the columns in the table, and the order of the columns in the Primary Key. 这似乎是由于表中各列的顺序与主键中各列的顺序之间的差异引起的。 Re-order the order of the xml entries to match the order of the Primary Key. 重新排列xml条目的顺序以匹配主键的顺序。

Having to 2 #1 I'm assuming is a bug - which I will report soon. 我假设必须达到2#1是一个错误-我将尽快报告。 However, is #2 above a bug or does changing the order mess with Doctrine's logic in some way? 但是,#2是不是在bug之上,还是以某种方式改变了秩序而违反了Doctrine的逻辑?

The more I think about this the more I believe it to be an oversight and not done intentionally. 我对这个问题的思考越深,我越相信它是一种疏忽,而不是故意的。 I was thinking there was something I was missing but I think these are issues with the library and have added them doctrine's JIRA. 我当时以为是我缺少的东西,但我认为这些是图书馆的问题,因此将它们添加到了教义的JIRA中。

EDIT: Links per request 编辑:每个请求的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM