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

Quoting problems with schema and dots in table name mapping #7329

Closed
guilliamxavier opened this issue Aug 1, 2018 · 1 comment
Closed

Quoting problems with schema and dots in table name mapping #7329

guilliamxavier opened this issue Aug 1, 2018 · 1 comment

Comments

@guilliamxavier
Copy link
Contributor

guilliamxavier commented Aug 1, 2018

Test entity:

/** @Entity @Table(TEST_VALUES_HERE) */
class Qux
{
    /** @Id @Column */
    public $id;
}

Test code:

echo $entityManager->createQuery('SELECT e FROM ' . Qux::class . ' e')->getSQL();

Full results:

Recap (master is simpler):

2.6 (current stable):

Issues:

  • both name="`other-b`.foo" and schema="`other-b`", name="foo" generate SELECT ... FROM `other-b`.foo (invalid SQL)
    and one must do name="other-b.`foo`" or schema="other-b", name="`foo`" to get a FROM "other-b"."foo" (which is still not exactly the wanted FROM "other-b".foo)
  • name="`foo.x`" generates SELECT ... FROM `foo.x` (invalid SQL)
    and there is no way to get a FROM "foo.x"
  • name="other.`foo.x`" generates SELECT ... FROM "other"."foo"."x" and
    schema="other", name="`foo.x`" generates SELECT ... FROM other.x` (invalid SQL)

Thoughts:

  • Option 1: Do not change anything, just document the current (surprising) behavior.
  • Option 2: Disallow dots in table names/schemas (via mapping validation).
  • Option 3: Handle backquotes on the schema [part] too, and properly handle backquoted dots:
    • both name="`other-b`.foo" and schema="`other-b`", name="foo" would generate a FROM "other-b".foo
      while name="other.`foo-a`" and schema="other", name="`foo-a`" would generate a FROM other."foo-a"
    • name="`foo.x`" would generate a FROM "foo.x"
      (name="other.foo" and schema="other", name="foo" still generating a FROM other.foo)
    • both name="other.`foo.x`" and schema="other", name="`foo.x`" would generate a FROM other."foo.x"

master (future 3.0):

Issues:

  • name="foo.x" generates SELECT ... FROM "foo"."x"
    and there is no way to get a FROM "foo.x"
  • schema="other.y", name="foo.x" generates SELECT ... FROM "other"."y"."foo"."x"
    and there is no way to get a FROM "other.y"."foo.x"

Thoughts:

  • Option 1: same as above (document)
  • Option 2: same as above (disallow)
  • Option 3: Drop support of the "dot-notation" (implicit schema, name="myschema.mytable"), and quote the (explicit) schema and the name separately:
    • name="foo.x" would generate a FROM "foo.x"
      (schema="other", name="foo" still generating a FROM "other"."foo")
    • schema="other.y", name="foo.x" would generate a FROM "other.y"."foo.x"
      (and no place anymore for a FROM "other"."y"."foo"."x")

What do you think?


History of the features:

@guilliamxavier guilliamxavier changed the title Problems with schema quoting in table name mapping Quoting problems with schema and dots in table name mapping Aug 9, 2018
@guilliamxavier
Copy link
Contributor Author

Additional info for master: it looks like support of implicit schema has been "implicitly" dropped in 8a4ca55 (search for '.' [2 occurrences] and for implicit_schema [6 occurrences])

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

No branches or pull requests

1 participant