Doctrine aliasing issue when column name starts with number #6033

Closed
opened 2026-01-22 15:25:06 +01:00 by admin · 3 comments
Owner

Originally created by @CheeseBites on GitHub (Aug 7, 2018).

Originally assigned to: @Ocramius on GitHub.

If the column name starts with a number the querybuilder doesn't wrap the alias in quotes,

Error returns:
An exception occurred while executing 'SELECT t0_.AA AS AA_0, t0_.BB AS BB_1, t0_.[12AA] AS 12AA_2 FROM [foo]'

What the query should look like
An exception occurred while executing 'SELECT t0_.AA AS AA_0, t0_.BB AS BB_1, t0_.[12AA] AS "12AA_2" FROM [foo]'

The code looks like this

$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('a')->from(foo::class, 'a');
$list = $queryBuilder->getQuery()->getResult();

Is there any workaround for this?

Originally created by @CheeseBites on GitHub (Aug 7, 2018). Originally assigned to: @Ocramius on GitHub. If the column name starts with a number the querybuilder doesn't wrap the alias in quotes, Error returns: `An exception occurred while executing 'SELECT t0_.AA AS AA_0, t0_.BB AS BB_1, t0_.[12AA] AS 12AA_2 FROM [foo]'` What the query should look like `An exception occurred while executing 'SELECT t0_.AA AS AA_0, t0_.BB AS BB_1, t0_.[12AA] AS "12AA_2" FROM [foo]'` The code looks like this ``` $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select('a')->from(foo::class, 'a'); $list = $queryBuilder->getQuery()->getResult(); ``` Is there any workaround for this?
admin added the Duplicate label 2026-01-22 15:25:06 +01:00
admin closed this issue 2026-01-22 15:25:06 +01:00
Author
Owner

@Ocramius commented on GitHub (Aug 7, 2018):

What ORM version are you on? I think this is already fixed by prefixing without numbers as start

@Ocramius commented on GitHub (Aug 7, 2018): What ORM version are you on? I think this is already fixed by prefixing without numbers as start
Author
Owner

@ostrolucky commented on GitHub (Aug 7, 2018):

Dupe of https://github.com/doctrine/doctrine2/issues/6965

@ostrolucky commented on GitHub (Aug 7, 2018): Dupe of https://github.com/doctrine/doctrine2/issues/6965
Author
Owner

@Ocramius commented on GitHub (Aug 7, 2018):

Closing as per @ostrolucky's findings

@Ocramius commented on GitHub (Aug 7, 2018): Closing as per @ostrolucky's findings
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6033