UUID are not sequenced, so pk comes back empty when the pk is a uuid.  S...

...hould check both fields if pk wasn't found in the first one.
Why did you end the if statement instead of adding another elsif?