Describe the bug
When using groupBy date the alias and field names in the generated SQL are not being properly escaped, resulting in an invalid query and failure.
With a backing Postgres data structure wherein the schema concerns a TypeORM ViewEntity class named UserRecord targeting the database schema tenant and view user.
After which an error is thrown by the database and introspection of the generated SQL for the query shows that the alias and field name in the TO_CHAR() function for the group by aggregate is not properly escaped in quotes, whereas the count aggregate is.
SELECT
DATE(TO_CHAR(UserRecord.createdAt, 'YYYY-mm-01')) AS "GROUP_BY_createdAt",
COUNT("UserRecord"."userId") AS "COUNT_userId"
FROM
"tenant"."user" "UserRecord"
GROUP BY
"GROUP_BY_createdAt"
ORDER BY
"GROUP_BY_createdAt" ASC
Expected behavior
The generated SQL does not error and results are subsequently returned.
Desktop (please complete the following information):
Describe the bug When using groupBy date the alias and field names in the generated SQL are not being properly escaped, resulting in an invalid query and failure.
Have you read the Contributing Guidelines?
Yes.
To Reproduce Steps to reproduce the behavior:
UserRecord
targeting the database schematenant
and viewuser
.After which an error is thrown by the database and introspection of the generated SQL for the query shows that the alias and field name in the
TO_CHAR()
function for the group by aggregate is not properly escaped in quotes, whereas the count aggregate is.Expected behavior The generated SQL does not error and results are subsequently returned.
Desktop (please complete the following information):
v20.6.0
v4.3.3