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

DBAL Query Builder Aliasing issue #3242

Closed
CheeseBites opened this issue Aug 8, 2018 · 4 comments
Closed

DBAL Query Builder Aliasing issue #3242

CheeseBites opened this issue Aug 8, 2018 · 4 comments

Comments

@CheeseBites
Copy link

CheeseBites commented Aug 8, 2018

Q A
Version 2.8.0

Support Question

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]'
SQLSTATE [42000, 102]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '12'. SQLSTATE [42000, 8180]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Statement(s) could not be prepared.'

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?

@morozov
Copy link
Member

morozov commented Aug 8, 2018

Linking a related issue: #3152.

@morozov
Copy link
Member

morozov commented Aug 8, 2018

@CheeseBites given that the example uses ORM's entity manager, are you sure it's a DBAL issue? AFAIK, ORM doesn't use DBAL to build SELECT queries.

@Ocramius
Copy link
Member

Ocramius commented Aug 9, 2018

Closing: this is for the ORM

@Ocramius Ocramius closed this as completed Aug 9, 2018
@Ocramius Ocramius assigned Ocramius and unassigned morozov Aug 9, 2018
@github-actions
Copy link

github-actions bot commented Aug 1, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants