Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Not possible to use a custom naming strategy (No column X on table Client_OAuth2) #24

Closed
intellix opened this issue May 17, 2015 · 7 comments · Fixed by #33
Closed

Not possible to use a custom naming strategy (No column X on table Client_OAuth2) #24

intellix opened this issue May 17, 2015 · 7 comments · Fixed by #33

Comments

@intellix
Copy link

I'm attempting to validate/drop/create my schema. With this module and a config like within: "apigility-oauth2-doctrine-skeleton" I'm getting the following error:

[Doctrine\DBAL\Schema\SchemaException]                             
  There is no column with name 'clientId' on table 'Client_OAuth2'. 

Can't quite work out what's causing it as the XML definitions look fine.

@intellix
Copy link
Author

This all works perfectly in your example repository so must be something within my own and I shall debug further. Apologies for not checking before!

@intellix
Copy link
Author

Ok, I've traced that this is caused by me using the UnderscoreNamingStrategy within my Db module.

@intellix intellix reopened this May 17, 2015
@intellix intellix changed the title No column with name 'clientId' on table 'Client_OAuth2' when running orm:validate-schema Not possible to use a custom naming strategy (No column X on table Client_OAuth2) May 17, 2015
@TomHAnderson
Copy link
Member

Can you provide an example application and/or enough source direction to duplicate the error? Supporting different naming strategies probably falls within the scope of this module.

@intellix
Copy link
Author

Basically, within my Module.php, I'm doing:

public function onBootstrap($e)
{
    $em = $e->getTarget()->getServiceManager()->get('doctrine.entitymanager.orm_default');
    $em->getConfiguration()->setNamingStrategy(new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_LOWER));
}

@TomHAnderson
Copy link
Member

I can duplicate the problem. I didn't find an easy solution. I look forward to your solution.

@intellix
Copy link
Author

Had a look into how it all works and traced it down to the <unique-constraint> within the Client entity definition: https://github.com/TomHAnderson/zf-oauth2-doctrine/blob/master/config/orm/ZF.OAuth2.Doctrine.Entity.Client.dcm.xml#L12

It seems like Doctrine doesn't currently support the ability to specify a property rather than column name. The quick fix I can see is copying the definitions provided and changing to an underscore. Not sure about long-term... Possible to dynamically provide a unique constraint?

@TomHAnderson
Copy link
Member

I fixed this with a dynamic index modification to the metadata directly. I even named the index based on the column name.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants