When you create common functions, it’s important to make sure any wrapped queries do one thing at a time.
Today I was working on a function I originally wrote that queried something based on a primary key and returned related data for 1…..n records.. It was then modified by someone else so that it had successive left joins. Consequently, other pages and functions assumed it was returning one row per entity found, while it was actually returning one row per another entity per entity.
I made the assumption that others would not make existing 1-dimensional queries multi-dimensional.
So basically, instead of getting the expected n items from this function, I got more like 8*n due to the 2 left joins. Equally exciting is the fact that the majority of that stuff was NULL.
When you are expecting a certain retval, don’t update a function to return something completely different or your coworker will spend 2 hours figuring out why your application isn’t working right.