Problem/Motivation
#2616724: Warn when trying to create a database table with a NOT NULL => FALSE primary key introduced a check which flags invalid primary keys in schema specifications. This check does not work for composite primary keys if they specify an explicit prefix length.
Proposed resolution
Fix Schema::ensureNotNullPrimaryKey for primary key specifications with explicit prefix length.
Remaining tasks
TestsFix- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3068310-composite-primary-key-prefix-length-8.patch | 3.43 KB | znerol |
| #6 | 3068310-composite-primary-key-prefix-length-6.patch | 3.43 KB | znerol |
| #6 | interdiff.txt | 1.1 KB | znerol |
| #2 | 3068310-composite-primary-key-prefix-length.patch | 2.96 KB | znerol |
| #2 | interdiff.txt | 950 bytes | znerol |
Comments
Comment #2
znerol commentedFix might look something like this.
Comment #5
tstoecklerHmm... tests without assertions are no longer allowed, maybe just collapse the two new test methods into one? Not sure what the best solution is.
Fix looks good, though.
Comment #6
znerol commentedOr just add an assertion. Regrettably there is no
Schema::primaryKeyExists()but we can useSchema::addPrimaryKeyand look for the exception.Comment #8
tstoecklerActually, I think this is the test that needs an assertion. The other one is fine because
setExpectedException()counts as an "assertion" as far as I know.Comment #9
znerol commentedRight.
Comment #10
znerol commentedPatch still applies.
Comment #11
tstoecklerThanks for the bump. still looks good, and test makes sense, as well. Let's do it!
Comment #12
mondrakeA fundamental/conceptual question here: are we sure we want to support partial lenght columns in a unique key context here (primary/unique keys)? IMHO it seems weird you design a table with fields that you want to be kind of unique via PK, then to have a PK that would fatally fail when trying to insert records that lead to duplicate key, which can happen if your field varies in the part that is not part of the key -- how are we going to decide which is the 'right' key and record?
Recently, Doctrine DBAL have introduced partial length support to indexes https://github.com/doctrine/dbal/pull/2412, but have done so only for indexes, that allow duplicated keys - not for primary/unique keys.
Comment #13
catchAgreed with #12, this seems like the wrong direction to me.
Comment #14
mondrakeFiled #3082239: Forbid limited length primary and unique keys, allow only in indexes, which is basically the opposite of what is being done here.
Comment #15
mondrakeComment #19
mondrakeI suggest to wont fix this.
Comment #20
znerol commentedBecause the patch is too trivial? Or because the bug is too obscure?
Comment #21
znerol commentedOh, I somehow missed #12. I completely agree, this is wontfix.