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

DDC-1360: Reserved words escaping fails when using multiple reserved words #1979

Closed
doctrinebot opened this issue Sep 3, 2011 · 13 comments
Closed
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

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 quotedparameter totrue 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.

If Doctrine allows to escape the reserved words, it should take into account this kind of usage as well.

@doctrinebot
Copy link
Author

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.

Cheers,

@doctrinebot
Copy link
Author

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.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

How much of this ticket does your commit from some weeks ago cover guilherme?

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed for 2.2

@doctrinebot
Copy link
Author

Comment created by elnur:

It still doesn't work. Tried on master.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

what kind of error do you get?

@doctrinebot
Copy link
Author

Comment created by @beberlei:

could reproduce the problem with table names and sequence names.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed.

@doctrinebot
Copy link
Author

Comment created by elnur:

I've just got fresh clones of doctrine-doctrine2, doctrine-dbal and doctrine-common — all on their master branches.

My entity has this annotation:

@ORM\Table(name="`user`.`user`")

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".

@doctrinebot
Copy link
Author

Comment created by elnur:

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.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

I keep trying until i fixed this, now with a commit into DBAL: doctrine/dbal@4cb8a99

Will be included in Beta 2

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot
Copy link
Author

Comment created by elnur:

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"`.

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.

Good job, thanks.

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

No branches or pull requests

2 participants