Generate database object function for comparing two objects and added tests for it.