Support caching upserts
netixx opened this issue · 0 comments
netixx commented
While debbugging, I saw that there was
// Check if the given statement looks like a standard Ent query (e.g. SELECT).
// Custom queries (e.g. CTE) or statements that are prefixed with comments are
// not supported. This check is mainly necessary, because PostgreSQL and SQLite
// may execute insert statement like "INSERT ... RETURNING" using Driver.Query.
if !strings.HasPrefix(query, "SELECT") && !strings.HasPrefix(query, "select") {
return d.Driver.Query(ctx, query, args, v)
}
in the code of "Query" in the driver.
If I understand correctly, this means that there is no support for upserts ?
On the top of my mind, I don't see any reason not to cache them. If we see an upsert query with exactly the same query and parameters as we have seen before, returning the same fields, we can use the cached value right ?