goqu icon indicating copy to clipboard operation
goqu copied to clipboard

Removal of double quotes around table name

Open psrikanth554 opened this issue 3 years ago • 3 comments

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

psrikanth554 avatar Mar 29 '21 10:03 psrikanth554

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

doug-martin avatar Mar 29 '21 16:03 doug-martin

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"

psrikanth554 avatar Mar 30 '21 05:03 psrikanth554