-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schema diff keeps thinking custom mapping types have changed #2596
Comments
Possibly strictly related to #2594 |
I'll try to find some time to write a test case so you can reproduce the issue more easily. |
@vicdelfant do you derive that particular custom type from a built-in concrete Doctrine type like |
It's not derived from a built-in type, but the type class does extend quite a few of our own types before extending I our actual project, however, the inheritance chain is as follows:
As you can see, we love inheritance 😉 If you suspect inheritance to be the culprit then let me know and I'll update the test repo so you can get a complete picture. |
@vicdelfant I think your problem is this line. It won't match |
Ah! Adding a It appears that there's a second issue with a custom type inheriting from |
@vicdelfant I don't quite understand the second issue. Isn't it expected behaviour that a column comment is created in the database if |
Yes, exactly, that's the weird thing... there's no DC2Type-comment, even with |
Maybe related to #2594? |
I'll check against |
I have the same problem when type is a child of Type code example: final class PhoneNumberType extends StringType
{
const NAME = 'phone_number';
public function getName()
{
return self::NAME;
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return parent::getSQLDeclaration(
array_merge(
$fieldDeclaration,
[
'length' => 16,
'fixed' => false
]
),
$platform
);
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return $value;
}
if (!$value instanceof PhoneNumber) {
throw new \InvalidArgumentException(sprintf(
'Value must be of type "%s" but "%s" was given.',
PhoneNumber::class,
is_object($value) ? get_class($value) : gettype($value)
));
}
return $value->getRawValue();
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return $value;
}
return new PhoneNumber($value);
}
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
} |
I'm still encountering this problem with |
@NaGeL182 or anyone that is experiencing an issue similar to this with doctrine and symfony: I was experiencing this issue as well for a custom type that extended the StringType. I didn't update the |
@ragboyjr thanks for the info but I still encounter it even if my const MONEYTYPE = 'money';
//...
public function getName()
{
return self::MONEYTYPE;
} and still encounter this error! |
@vicdelfant public function getName()
{
return self::MONEYTYPE;
}
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
public function canRequireSQLConversion()
{
return true;
} and it still does it. |
hey, this seems to be fixed in |
I made value object as dbal type, and every field in mapping file represents as different every time. This overrides helps me to prevent creating same migrations for diff when mapping files same every time. thx |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm working on a relatively large project with a lot of custom mapping types (primarily value objects with UUIDs such as
OrderId
,InvoiceId
etc.). For some reason,schema:update
insists on re-creating all columns that contain such a custom type:Mapping types are properly registered,
requiresSQLCommentHint
is set to returntrue
for all types, theDC2Type
comment is correctly being added to the field definition (confirmed in the MySQL tables), storing and retrieving data works perfectly... everything but the schema comparison.The types are registered through a dedicated service, but in a nutshell the process is as follows:
AbstractPlatform::$doctrineTypeComments
contains all types so they're being processed just fine. Re-creating the entire database doesn't help either, and this obviously also affects migrations andschema:validate
.What am I missing here?
I came across the following similar issues but none of them solved my issue:
The text was updated successfully, but these errors were encountered: