How to fix Stack depth limit exceeded in PostgreSQL | DevErrors