fix query rebuilding using #unscoped