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

MySQL. Incorrect table alias escaping with " instead of ` #434

Open
2 tasks
lesichkovm opened this issue Oct 26, 2024 · 1 comment
Open
2 tasks

MySQL. Incorrect table alias escaping with " instead of ` #434

lesichkovm opened this issue Oct 26, 2024 · 1 comment

Comments

@lesichkovm
Copy link

lesichkovm commented Oct 26, 2024

Describe the bug
Incorrect table alias escaping with " instead of `

To Reproduce

innerq := q.Select("ip_address").Distinct()
q := goqu.Select(goqu.COUNT(goqu.Star()).As("count")).From(innerq)

generates:

SELECT COUNT(*) AS "count" FROM (SELECT DISTINCT `ip_address` FROM `stats_visitor` WHERE ((`created_at` >= '2024-10-25 00:00:00') AND (`created_at` <= '2024-10-25 23:59:59')) ) AS "t1" LIMIT 1

throws:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"t1" LIMIT 1

Expected behavior

SELECT COUNT(*) AS "count" FROM (SELECT DISTINCT `ip_address` FROM `snv_stats_visitor` WHERE ((`created_at` >= '2024-10-25 00:00:00') AND (`created_at` <= '2024-10-25 23:59:59')) ) AS `t1` LIMIT 1

Dialect:

  • postgres
  • [ x] mysql
  • sqlite3

Additional context
Current workaround:

sqlStr = strings.Replace(sqlStr, `AS "t1"`, "AS `t1`", 1)
@AngleZhou
Copy link

I found the solution in a closed issue
#68 (comment)

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

No branches or pull requests

2 participants