Conversation
MKodde
left a comment
There was a problem hiding this comment.
Nice work! We had a small discussion IRL where I questioned the current solution:
- Could you make a more 'generic' solution for the object and array types that you now added. This would need to include passing the type of the array items that are stored for additional type checking. And maybe passing a max length as some types have different requirements for that..
- Keep the current setup but add some additional (unit or integration) tests. I've found a couple of unit tests for two of the existing types
Question: are the types used in the existing functional tests? Or are they bypassed by the custom mock solution?
| * @var string[] | ||
| */ | ||
| #[ORM\Column(name: 'allowed_idp_entity_ids', type: \Doctrine\DBAL\Types\Types::ARRAY, length: 6777215)] | ||
| #[ORM\Column(name: 'allowed_idp_entity_ids', type: 'json', length: 16777215, nullable: true)] |
There was a problem hiding this comment.
Was the (significant) length increase intentional?
I also see that the field became nullable, but that is now explicitly set for all of the updated columns. I'm assuming that was previously the default setting which now needs an explicit setting.
There was a problem hiding this comment.
@johanib Note to self: Do we really want this? Better to avoid a migration and make specific types for the fields that use array, or copy the Array type into EB.
There was a problem hiding this comment.
Error: Use SimpleArray, json is fundamentally different and requires a migration.
There was a problem hiding this comment.
@MKodde I checked the length with: #1861 (comment)
Its currently mediumtext on prod, so it should be 16777215. I htink 6777215 was a typo.
805c922 to
271256a
Compare
| * @var string[] | ||
| */ | ||
| #[ORM\Column(name: 'allowed_idp_entity_ids', type: \Doctrine\DBAL\Types\Types::ARRAY, length: 6777215)] | ||
| #[ORM\Column(name: 'allowed_idp_entity_ids', type: 'json', length: 16777215, nullable: true)] |
There was a problem hiding this comment.
Error: Use SimpleArray, json is fundamentally different and requires a migration.
271256a to
cb43e68
Compare
cb43e68 to
fdc995d
Compare
fdc995d to
84b50bb
Compare
kayjoosten
left a comment
There was a problem hiding this comment.
Test are still failing
6f86ba5 to
074c48f
Compare
b019847 to
29b6168
Compare
|
| /** | ||
| * @var Organization | ||
| */ | ||
| #[ORM\Column(name: 'organization_nl_name', type: \Doctrine\DBAL\Types\Types::OBJECT, nullable: true, length: 65535)] |
There was a problem hiding this comment.
Let me start by complimenting you on this change. This makes the PR so much more to the point!
Two things caught my eye:
- Is there no need to set the column length anymore? Did we set the default value excessively before?
- And, I was also triggered by you setting the
nullablevalue for each field now. I'm OK with that, before we would only set it if the non-default value was required. - Does this change cause 0 schema changes? If it does, you might need to think about a strategy to roll out that change safely. But I guess there are none judging the code.
There was a problem hiding this comment.
As discussed.
Do not pass default values. So I removed the nullable: false.
This makes it in-line with the removed default lengths.
It does not result in any db schema changes, but will dig into that to see why the changed nullable: does not result in changes.
There was a problem hiding this comment.
I will revert the nullable: false changes.
The reason is that we use inheritance: IdentityProvider and ServiceProvider both extend the AbstractRole. So doctrine enforces all fields in the children als nullable: false. Which makes sense.
So adding nullable: false is plain misleading.
| * @var IndexedService[] | ||
| */ | ||
| #[ORM\Column(name: 'assertion_consumer_services', type: \Doctrine\DBAL\Types\Types::ARRAY, length: 65535)] | ||
| #[ORM\Column(name: 'assertion_consumer_services', type: SerializedArrayType::NAME, nullable: true)] |
There was a problem hiding this comment.
@kayjoosten raised the question: Why is are these fields made nullable: true.
A: To mirror the database, where they are currently nullable.
Weirdly, changing nullable to true / false does not result in schema changes. I will look into this to make sure.
There was a problem hiding this comment.
Doctrine forces these fields to nullable, as this entity inherits from the AbstractRole and shares the same table with IdentityProvider.
I will remove them and add a comment to the AbstractRole.
17fbd2f to
dbadae3
Compare
| * @var Organization | ||
| */ | ||
| #[ORM\Column(name: 'organization_nl_name', type: \Doctrine\DBAL\Types\Types::OBJECT, nullable: true, length: 65535)] | ||
| #[ORM\Column(name: 'organization_nl_name', type: SerializedObjectType::NAME, length: 65535, nullable: true)] |
There was a problem hiding this comment.
Another detail: Currently, on prod, this is a TEXT. In order to keep it TEXT, pass the correct length. Otherwise, it will be mapped to a LONGTEXT.
- The old array / object serialization types from doctrine have been moved / integrated into our codebase for backward compatability. - Fix typo in allowed_idp_entity_ids. The db is a medium text, which is 16777215 bytes. This change aligns the column with the mapping. - Make the nullable: false explicit to avoid future confusion. Confusion could stem from the fact that the fields are nullable in code, but not nullable in the database. This is because a serialized `null` results in something like `s:` in the database.
dbadae3 to
b83392f
Compare
Needed for SF 6.4