Jira issue originally created by user elnur:
Everything works fine when I use the @Table annotation like this: @Table(name="user"). But when the user table is in the user schema and I try to use the annotion in this way: @Table(name="user.user") — everything falls apart.
A quick look into the code showed that it checks if the table name starts with , and if it does, it sets the `quoted` parameter to `true` and removes the characters on the both sides. So, if I quote the both words like @Table(name="user.user"), the table name becomes "user.user" and it, of course, fails. If I quote it just like @Table(name="user.user"), the table name becomes "user.user", which fails too.
, and if it does, it sets the `quoted` parameter to `true` and removes the
If Doctrine allows to escape the reserved words, it should take into account this kind of usage as well.
Comment created by @guilhermeblanco:
By now, it's currently impossible to do cross database joins in an easy way.
We have planned it through the schema support in @Table.
I'll be working on this support for 2.2, but until there, my only recommendation is to not use a keyword as a table name.
Comment created by elnur:
It's not cross database; it's just schema.table in PostgreSQL. It works when not using reserved words, but fails with them.
Comment created by @beberlei:
How much of this ticket does your commit from some weeks ago cover guilherme?
Fixed for 2.2
It still doesn't work. Tried on master.
what kind of error do you get?
could reproduce the problem with table names and sequence names.
I've just got fresh clones of doctrine-doctrine2, doctrine-dbal and doctrine-common — all on their master branches.
My entity has this annotation:
I'm getting the following exception:
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "user.user"
does not exist LINE 1: ... is_private9,
u0*.created_at AS created*at10 FROM "user.user...
So, it's translating user`.`user to "user.user", while it should be "user"."user".
What changed is that earlier user`.`user was translated to "user.user", while now it's translated to "user.user", but should be to "user"."user".
I saw the commit related to this ticket (959a686) and I want to note that I'm getting this error not_ when creating a table, but when _querying it. I don't use Doctrine for creating tables anyway — I do it via plain SQL.
I keep trying until i fixed this, now with a commit into DBAL: doctrine/dbal@4cb8a99
Will be included in Beta 2
Issue was closed with resolution "Fixed"
Now user`.user`,user.useranduser.userget escaped properly, ending up as `"user"."user"`. Interestingly enough, even only the beginning tick like inuser.userends up as"user"."user"`.
get escaped properly, ending up as `"user"."user"`. Interestingly enough, even only the beginning tick like in
ends up as
user.user, though, results in `user.`user — that is, nothing gets escaped. I don't think this is a big deal, because if I can escape both schema and table name parts, then I won't run into problems. I'm pointing this out in case it was intended to affect the escaping too.
, though, results in `user.`user
Good job, thanks.