Open
Description
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)
Metadata
Assignees
Labels
No labels
Activity