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

Fix getSQLTableAlias for postgre camelized table name #624

Closed
wants to merge 2 commits into from

Conversation

cedriclombardot
Copy link

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

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
@doctrinebot
Copy link

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

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use '"'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you removed strtolower, which broke tests.

@Majkl578
Copy link
Contributor

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

@cedriclombardot
Copy link
Author

Yes #615 should work !

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

Successfully merging this pull request may close these issues.

3 participants