Fix #2406 query builder cache

See #2406

Signed-off-by: GDmac