Issue in Ruby and Rails upgrade

Hi, I have an application where I recently upgraded Ruby from version 2.7.2 to 3.1.6, and Rails from 5.1.6 to 6.1.7. After the upgrade, everything seems to be working except for the find and find_by_id methods. These methods are not returning results as expected, even though the ID is correctly set as the primary key. I checked for any method overrides, but there are none. The ORM query generated for find_by_id seems to have id as nil. What’s odd is that running a raw SQL query using the ID works perfectly.

Has anyone encountered this issue, or does anyone have suggestions on how to resolve it?

Thanks in advance!