goqu
goqu copied to clipboard
Removal of double quotes around table name
Is your feature request related to a problem? Please describe. I am facing an issue with double quotes for the table name. When executing a query I always get Error 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
Describe the solution you'd like I figured out its because of the doublequotes
Dialect
- [ ] mysql
Can you provide an example of how you are setting up your dataset and executing the query? It sounds like the dialect is not being set to mysql
- https://pkg.go.dev/github.com/doug-martin/goqu/v9#example-Dialect-DatasetMysql
whereApartment := []goqu.Expression{ goqu.L("property_id").Eq(propertyId), }
apartmentQuery := goqu.Dialect("mysql").
Select(
goqu.L("type"),
goqu.L("label"),
).
From("apartment").
Where(whereApartment...)
apartmentSql, _, _ := apartmentQuery.ToSQL()
fmt.Println(apartmentSql)
apartmentRows, err := db.Query(apartmentSql)
I tried this.. this was throwing an error
"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 '\"apartment\" WHERE (property_id = '1044')' at line 1"
Looks like you are not importing the dialects. NOTE Dialects work like drivers in go where they are not registered until you import the package.