Join table name are wrong when a platform can emulate schemas #5101

Closed
opened 2026-01-22 14:58:22 +01:00 by admin · 3 comments
Owner

Originally created by @qpautrat on GitHub (Apr 15, 2016).

Originally assigned to: @lcobucci, @greg0ire on GitHub.

Hello everyone,

Considering this schema:

Product:
  type: entity
  table: products
  schema: test
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    name:
      type: string
  manyToMany:
        options:
            targetEntity: Option
            joinTable:
                name: product_option
                schema: test
                joinColumns:
                  product_id:
                    referencedColumnName: id
                inverseJoinColumns:
                  option_id:
                    referencedColumnName: id

Option:
  type: entity
  table: options
  schema: test
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    label:
      type: string

Create command orm:schema-tool:drop --dump-sql is giving me following sql statements:

CREATE TABLE test__options (id INTEGER NOT NULL, label VARCHAR(255) NOT NULL, PRIMARY KEY(id));
CREATE TABLE test__products (id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));
CREATE TABLE test__product_option (product_id INTEGER NOT NULL, option_id INTEGER NOT NULL, PRIMARY KEY(product_id, option_id), CONSTRAINT FK_F811B85D4584665A FOREIGN KEY (product_id) REFERENCES test__products (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_F811B85DA7C41D6F FOREIGN KEY (option_id) REFERENCES test__options (id) NOT DEFERRABLE INITIALLY IMMEDIATE);
CREATE INDEX IDX_F811B85D4584665A ON test__product_option (product_id);
CREATE INDEX IDX_F811B85DA7C41D6F ON test__product_option (option_id);

But when I want to drop my schema, many to many relation table is missing in sql statements:
orm:schema-tool:drop --dump-sql

DROP TABLE test__options;
DROP TABLE test__products

This is happening because DefaultQuoteStrategy::getJoinTableName() does not care about platform which can emulate schema unlike getTableName().

Originally created by @qpautrat on GitHub (Apr 15, 2016). Originally assigned to: @lcobucci, @greg0ire on GitHub. Hello everyone, Considering this schema: ``` yaml Product: type: entity table: products schema: test id: id: type: integer generator: strategy: AUTO fields: name: type: string manyToMany: options: targetEntity: Option joinTable: name: product_option schema: test joinColumns: product_id: referencedColumnName: id inverseJoinColumns: option_id: referencedColumnName: id Option: type: entity table: options schema: test id: id: type: integer generator: strategy: AUTO fields: label: type: string ``` Create command `orm:schema-tool:drop --dump-sql` is giving me following sql statements: ``` sql CREATE TABLE test__options (id INTEGER NOT NULL, label VARCHAR(255) NOT NULL, PRIMARY KEY(id)); CREATE TABLE test__products (id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)); CREATE TABLE test__product_option (product_id INTEGER NOT NULL, option_id INTEGER NOT NULL, PRIMARY KEY(product_id, option_id), CONSTRAINT FK_F811B85D4584665A FOREIGN KEY (product_id) REFERENCES test__products (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_F811B85DA7C41D6F FOREIGN KEY (option_id) REFERENCES test__options (id) NOT DEFERRABLE INITIALLY IMMEDIATE); CREATE INDEX IDX_F811B85D4584665A ON test__product_option (product_id); CREATE INDEX IDX_F811B85DA7C41D6F ON test__product_option (option_id); ``` But when I want to drop my schema, many to many relation table is missing in sql statements: `orm:schema-tool:drop --dump-sql` ``` sql DROP TABLE test__options; DROP TABLE test__products ``` This is happening because [`DefaultQuoteStrategy::getJoinTableName()`](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php#L97) does not care about platform which can emulate schema unlike [`getTableName()`](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/DefaultQuoteStrategy.php#L47).
admin added the Bug label 2026-01-22 14:58:22 +01:00
admin closed this issue 2026-01-22 14:58:22 +01:00
Author
Owner

@ptkoz commented on GitHub (Nov 23, 2019):

Any chance to get that solved? The PR is up for over 3 years now. Happy to help bringing it over the line.

@ptkoz commented on GitHub (Nov 23, 2019): Any chance to get that solved? The PR is up for over 3 years now. Happy to help bringing it over the line.
Author
Owner

@greg0ire commented on GitHub (Nov 24, 2019):

@pamelus I commented on the PR. If you see on activity, you can address my comments yourself.

@greg0ire commented on GitHub (Nov 24, 2019): @pamelus I commented on the PR. If you see on activity, you can address my comments yourself.
Author
Owner

@lcobucci commented on GitHub (Nov 25, 2019):

Can you check if this happens in 2.7.0? https://github.com/doctrine/orm/pull/7079 should have solved this.

@lcobucci commented on GitHub (Nov 25, 2019): Can you check if this happens in 2.7.0? https://github.com/doctrine/orm/pull/7079 should have solved this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5101