Handle query merge logic outside server['queries'] scope and set at end