Skip to content
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

postgres multiple schema creates invalid entities #7000

Closed
pursehouse opened this issue Jan 21, 2018 · 7 comments
Closed

postgres multiple schema creates invalid entities #7000

pursehouse opened this issue Jan 21, 2018 · 7 comments
Assignees

Comments

@pursehouse
Copy link

Running the command for a postgres database project with multiple schemas

./vendor/doctrine/doctrine-module/bin/doctrine-module orm:convert-mapping --namespace="Application\Entity\" --from-database annotation ./module/Application/src/

creates php class entities in the format of "Schemaname.tableName" like this

use Doctrine\ORM\Mapping as ORM;

/**
 * Incoming.market
 *
 * @ORM\Table(name="incoming.market")
 * @ORM\Entity
 */
class Incoming.market
{

which is obviously an invalid class name.
Shouldn't doctrine be putting the schema into the namespace instead of breaking the class name?

@Ocramius
Copy link
Member

No, this is a long standing issue that was never solved because not worth solving, as the entity generators are being deprecated (2.7) and removed (3.0) from the ORM.

Specifically, any kind of special character in the name of the table will result in an invalid class name.

Closing as won't fix

@pursehouse
Copy link
Author

Invalid table name characters? That doesn't match what I am talking about... The table name is "market", the schema name is "incoming".
So there will no longer be any way to create entities from the existing database? Every class will have to be made by hand?

@pursehouse
Copy link
Author

if this was never solved, how does the community use doctrine with multiple schemas?

@Ocramius
Copy link
Member

Invalid table name characters?

Try a dash or a space in a table name, for example.

So there will no longer be any way to create entities from the existing database?

Yes, just not in core ORM. There are already existing tools for generating code when given mapping definitions, so we will provide a migration path, but we no longer endorse nor support the practice in this project due to widespread abuse of these tools, leading to extremely anemic, under-performing and hard to maintain software projects (plus the ORM gers the blame for that: combo!)

Every class will have to be made by hand?

At least with ORM core only (this project): yes.

As for your current scenario, the fix is quite easy to get you back on track, as the tools are gonna stay in 2.x:

You'd generate the files, then grep over those with the names that cannot (obviously) parse in PHP and rename them.

The entity generator was supposed to just be giving projects a kick-start, not a fully usable set of entities, as these entities are bare data structures with little to no use.

@Ocramius
Copy link
Member

Related: #6902
Related: #6870

@pursehouse
Copy link
Author

how does doctrine even work without those classes being generated in the doctrine format then? Isn't it a requirement?

@Ocramius
Copy link
Member

You just adapt the generated code.

Doctrine works just fine as long as the annotations or XML table and schema mappings match your DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants