goqu
goqu copied to clipboard
Disabling the quotes to wrap schema/table/column in statements
Hi,
Is there a chance to disable escaping schema, stable, or column names with "
because it makes it hard to write a custom statement for the .Select()
method?
Let's say, there are two inner joins to the table, and I want to return the results of this inner joins as JSON objects:
query, params, err := goqu.From(goqu.S("piblic").Table("a")).
Select(
`json_buil_obj(
"id", joinedTableA.id,
"name", joinedTableA.name,
)`,
`json_buil_obj(
"id", joinedTableB.id,
"name", joinedTableB.name,
)`
).
Where(...some condition...).
InnerJoin(..,..).
InnerJoin(..,..).
ToSQL()
The SQL statement that would be generated would be invalid because there would be a few places with double escaping like:
""."
My intent is to return the whole response as a JSON object/array later to avoid the complexity of column-to-field matching (I assume that JSON unmarshaling from the response would provide greater flexibility with very little overhead).
Describe the solution you'd like Allow disabling the schema/table/column escaping:
InnerJoin(..,..).
NoEscaping(true).
ToSQL()
Dialect
- [X] postgres
- [ ] mysql
- [ ] sqlite3