This PR rewrites Engine.QuoteTo() so the following cases are handled properly:
NOTE: I'm using ' instead of backticks because I can't escape inline backticks in the text.
When engine.SetSchema() is used, a new part of the table identifier is added. For example, if we had table issue, now the identifier becomes schema.issue. However, the problem comes when identifiers are quoted. For example in:
err = e.Table("`user`").
Join("INNER", "issue_assignees", "assignee_id = `user`.id").
Where("issue_assignees.issue_id = ?", issue.ID).
The generated query looks like this:
SELECT * FROM "schema5152".""user""
INNER JOIN schema5152.issue_assignees ON assignee_id = "user".id
WHERE (issue_assignees.issue_id = $1)
As one can see, user is not properly quoted in the FROM part of the statement. This is because Engine.tbNameWithSchema() adds the schema, and then QuoteTo() receives schema.'user' as the table name (with backticks).
@lunny with this PR I've been able to make go-gitea/gitea#8819 work in all my tests (complex queries, exec, table user, etc.)
Mmmm..... CI fails. I'll have to work more on this.
How can CI be restarted?
Oh, I see, CI was waiting for a comment from me (or it was you who restarted it?) :smile:
@lunny tests passing. :smile:
No due date set.
This pull request currently doesn't have any dependencies.
Deleting a branch is permanent. It CANNOT be undone. Continue?