Skip to content

Fix getSQLTableAlias for postgre camelized table name #624

Closed
wants to merge 2 commits into from

3 participants

@cedriclombardot

In postgreSQL with old databases we can have camelized model names to query on we need to add quote around the table name like :

 * @ORM\Table(name="""someThing""")

But when query is built the alias taken will be " this fix will find the good alias to use enabling to query camelized tables

@cedriclombardot cedriclombardot Fix getSQLTableAlias for postgre camelized table name
In postgreSQL with old databases we can have camelized model names to query on we need to add quote around the table name like :

```
 * @ORM\Table(name="""someThing""")
```

But when query is built the alias taken will be `"` this fix will find the good alias to use enabling to query camelized tables
cc53441
@doctrinebot

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2362

@Majkl578 Majkl578 commented on an outdated diff Mar 22, 2013
lib/Doctrine/ORM/Query/SqlWalker.php
@@ -284,7 +284,9 @@ public function getSQLTableAlias($tableName, $dqlAlias = '')
$tableName .= ($dqlAlias) ? '@[' . $dqlAlias . ']' : '';
if ( ! isset($this->tableAliasMap[$tableName])) {
- $this->tableAliasMap[$tableName] = strtolower(substr($tableName, 0, 1)) . $this->tableAliasCounter++ . '_';
+ $prefix = (substr($tableName, 0, 1) != "\"") ? substr($tableName, 0, 1) : substr($tableName, 1, 1);
@Majkl578
Majkl578 added a note Mar 22, 2013

Why don't you use '"'?

@Majkl578
Majkl578 added a note Mar 22, 2013

And you removed strtolower, which broke tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Majkl578

By the way, this PR collides with another one: #615 (which would also solve this issue in different, IMO cleaner way).

@cedriclombardot

Yes #615 should work !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.