Fixing bug where SelectByKey fails for records without any keys (malformed SQL emitted).