-
-
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 generator is not adding COMMENT
to custom types
#2594
Comments
Does the comment appear when using `orm:schema:create --dump-sql`? What
does the custom type look like?
…On 10 Jan 2017 21:21, "Florian Krauthan" ***@***.***> wrote:
I am using the DoctrineEnumBundle and have a issue with the enum SQL that
gets generated. It does not contain the COMMENT field which is required to
identify the enum type correctly.
I've opened a ticket at the DoctrineEnumBundle which contains a lot more
information about this case fre5h/DoctrineEnumBundle#87
<fre5h/DoctrineEnumBundle#87>
Information that might be important right of the bet are I am running
MariaDB on Windows in Version10.1.20.
Please let me know if you need any other information.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2594>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakBdZa1tCBXzZ3k5eGf81QVOM2sqwks5rQ-gugaJpZM4Lf2gj>
.
|
No it does not appear:
And my custom type looks like this: <?php
namespace AppBundle\DBAL\Type;
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
class FlowerStateType extends AbstractEnumType {
const SEED = 'seed';
const GERM = 'germ';
const MATURE = 'mature';
protected static $choices = [
self::SEED => 'Seed',
self::GERM => 'Germ',
self::MATURE => 'Mature',
];
} And I use this state like this in my entity: /**
* @var string
*
* @ORM\Column(type="FlowerState")
*
* @DoctrineAssert\Enum(entity="AppBundle\DBAL\Type\FlowerStateType")
*/
protected $state; |
Wondering if |
Any way how I can try debugging this/helping you guys to find the issue? This is really bugging me as it requires all my auto generated migration sqls to be manual adjusted. |
@fkrauthan a test case is needed. My suspicion is that this is the culprit. What you want is two tests:
Removing that comment and trying your schema generation again should also tell you if that's the culprit, and which part of the code is skipping generating the comment. As for |
Hmm how do I change that schema generation checks? It is just weird coz the enum is recognized as enum. Its just the required NOTE is not added to the enum which results in Doctrine thinking that enum does not exist and the next migration contains again a column change to make it a enum. |
Doctrine thinks that your |
Oh you mean when it is reading it from the database? But again the developer of the DoctrineEnumBundle says there should be a database comment added when generating the schema or is this because a enum is a sort of true database feature and not a 100% custom type? |
Yep
The reason the comments are supposed to be added is that doctrine can't understand a custom type otherwise. For instance, let's say that you have an I suggest checking that particular line that I referenced, and if that's not it, then a test case doing schema introspection is needed. |
@fkrauthan you will have to make sure the platform knows that custom requires a comment IIRC: Type::addType($name, $class);
$platform->registerDoctrineTypeMapping($name, $name);
$platform->markDoctrineTypeCommented($name); Can you check if that helps? |
See also: doctrine/DoctrineORMModule#267 |
@deeky666 it looks like the https://github.com/fre5h/DoctrineEnumBundle/blob/c73dc724b2d2f18600e1ffb246b017c8f51085ab/DBAL/Types/AbstractEnumType.php file (the base type class) contains a Still have to try @Ocramius tests. |
@fkrauthan unfortunately I really don't know. Have not been around at the time this was implemented. @beberlei do you remember? |
Based on comments in https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/Type.php this is exactly what that method should be used for. |
@fkrauthan I know it is. But it is not evaluated in |
The problem is I am using Symfony and therefor have no control over executing a custom type registration (I define it in my config file). |
@fkrauthan if you use Symfony you probably also use DoctrineBundle? Because it seems to be integrated into DoctrineBundle: https://github.com/doctrine/DoctrineBundle/pull/21/files Still this can be fixed in DBAL transparently. |
Ok that means this will be already marked as commented type as the default value is |
@fkrauthan you would have to debug whether your type gets commented by DoctrineBundle then, this is out of scope for us. Meanwhile I will prepare a patch for implicit marking via |
@fkrauthan PR created: #2603 |
@fkrauthan check if current |
Closing this as fixed. If you still have issues with current |
Hey I just updated my In addition to that I followed @Ocramius recommendation and commented out the line
Do you guys have any other ideas where I could start debugging why the COMMENT is not attached even so my enum is a Custom Type within my code? |
@fkrauthan does the exception occur when running |
@fkrauthan please try to isolate the issue to DBAL code only, otherwise it's hard for us to get into the problem. I suggest you try to create a DBAL test case and see if you can get the issue reproduced. To me it still looks like some misconfiguration or bug in the bundle(s) you use, as we have a lot of successful tests around that kind of thing. |
That is not so easy as I am running into that issue in combination with Symfony and a Symfony Bundle that extends DBAL. Would it help if I set up a mini symfony installation just using that bundles related to the enum for testing? |
Unlikely, since we never get the time to check full stacks. The issue needs to be reproduced within our suite, without symfony interaction... |
@fkrauthan you could try debugging your setup and check if the custom type is registered as commented type in the DBAL platform. Should not be so hard. Just put in some |
Sure. I am not very familiar with dbal so if you could pin point me to a couple of locations where I should place some var_dumps and what I should see that would help me a lot. |
@fkrauthan the interesting parts are here and here |
Ok the second method |
I might have found something in the DoctrineBundle code. The ConnectionFactory.php#L60 registers custom types (and detects correctly that my custom types should be commented/adding it to the $commentedTypes variable). But when createConnection is called $mappingTypes is an empty array and therefor the for loop that looks thru all commentedTypes and calls I guess I should open a ticket at the DoctrineBundle github repo? The only thing that is still a bit weird to me is why this is even required? The |
@fkrauthan we did something about this in DBAL, but currently only available in |
Is there already a timeline to release that as a new version? |
@fkrauthan nope |
COMMENT
to custom types
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 am using the DoctrineEnumBundle and have a issue with the enum SQL that gets generated. It does not contain the COMMENT field which is required to identify the enum type correctly.
I've opened a ticket at the DoctrineEnumBundle which contains a lot more information about this case fre5h/DoctrineEnumBundle#87
Information that might be important right of the bet are I am running MariaDB on Windows in Version
10.1.20
.Please let me know if you need any other information.
The text was updated successfully, but these errors were encountered: