Open sgrishanin opened 1 year ago
This bit me as well, and the bug that came out of it was very challenging to debug.
I got panic with same bug, triggered by FromQuery()
:
sd := db.
Select(...).
From(...).
Where(...)
db.Insert(...).FromQuery(sd).Executor().Exec()
Reported error:
incompatible dialects for INSERT ("default") and SELECT ("default")
Describe the bug
WithDialect
changes the dialect of the receiver dataset, but datasets of CTEs inside it keep the default dialect (unless specified explicitly). The resulting query contains multiple incompatible dialects.To Reproduce
Expected behavior When the query is being build, I expect it to have a dialect of the main dataset I call
.ToSQL()
on. I think it should never produce a potentially impossible query.Dialect:
Additional context Explicitly setting the same dialect on every CTE does the job of course, but it is not obvious and simply cumbersome.