Fix handling of NULLs when replacing query params