There is no explicit guarantee of the order of keys according to mapping information anywhere in the code, hence why there's no way to force it to do something else than what you are getting as a result.
You can try reordering fields, reordering entity properties, etc, but the order may change due to implementation details of the ORM (the "guarantee" bit I was talking about) in an upgrade. This can surely be fixed by freezing current behaviour within an integration tests, in which case some minimal regression prevention would emerge, but otherwise it isn't really defined in docs/mappings how the order is decided.. If you want, you can write such test and then figure out which combination defines the key components order, which we can then document. On Sat, 1 Dec 2018, 00:32 James Moser <[email protected] wrote: > I'm actually pretty surprised to hear that. If it doesn't guarantee any > order, why is it trying to reorder them at all then? > > A manual migration isn't going to help me here... I don't want to change > anything, I want to prevent doctrine from thinking it needs to change > something. > > > On Wednesday, November 28, 2018 at 9:40:59 AM UTC-8, Marco Pivetta wrote: >> >> I'd avoid YML mappings overall, since they are deprecated and removed >> from ORM `master`. >> >> Still, order of columns in a key is not guaranteed anywhere in the ORM, >> so there's no real way to enforce the DDL to match your requirements. >> Consider using manually crafted doctrine migrations instead. >> >> On Wed, 28 Nov 2018, 18:09 James Moser <[email protected] wrote: >> >>> I'm having problems setting a field order in a composite primary key. >>> It seems doctrine is prioritizing the scalar type over the association keys? >>> >>> id: >>> first: >>> associationKey: true >>> second: >>> associationKey: true >>> third: >>> type: string >>> nullable: false >>> length: 2 >>> options: >>> fixed: false >>> default: A >>> id: true >>> column: third >>> >>> It produces: >>> >>> PRIMARY KEY (third, first, second) >>> >>> when I need it to match the existing table, which has: >>> >>> PRIMARY KEY (first, second, third) >>> >>> I can't find anything about ordering the fields in a composite key in >>> the docs. Is this normally done through the order listed in YML? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "doctrine-user" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/doctrine-user. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > You received this message because you are subscribed to the Google Groups > "doctrine-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/doctrine-user. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
