There is at least one bug in The Bug Genie bugtracker cause by Query checking already generated sql string.
Here you can see working not as expected code because Query already compiled as SELECT statement here and actually not deleting anything.
Of course you can try to make some kind of complex cache validating but I don't think it's worth it.
How to reproduce(pseudo code):
$query = Query();
$query->where(<add some conditions>);
$result = $table->select($query);
// instead of deleting actually will be executed last Select query
$table->delete($query);
or few same action with a little bit changed Query:
$query = Query();
$query->where(<add some conditions>);
$result1 = $table->select($query);
$query->where(<add some another conditions>);
// actually will be executed previous Select query
$result2 = $table->select($query);
There is at least one bug in The Bug Genie bugtracker cause by Query checking already generated sql string.
Here you can see working not as expected code because Query already compiled as SELECT statement here and actually not deleting anything.
Of course you can try to make some kind of complex cache validating but I don't think it's worth it.
How to reproduce(pseudo code):
or few same action with a little bit changed Query: