Fix for Lookup Failure Due to Custom Column Names in WeWeb

RICE
Thu, 24 Oct 2024 02:49:09 +0000
Tips and Hacks

Hi everyone,

I wanted to share a bug I encountered and the solution I found, in case it helps someone else.

I have my WeWeb setup with Supabase for the backend, with three key tables: clients, vehicles, and bookings. Each table has a unique ID column (client_id, vehicle_id, and booking_id respectively), which I renamed from the default id for clarity.

In the bookings table, I use foreign keys to link client_id and vehicle_id from the clients and vehicles tables, so my booking data only contains the IDs instead of full client and vehicle info.

Everything worked fine until I hit an issue while trying to bind the data on the frontend. The lookup function failed when trying to retrieve related data using the foreign key columns. After much trial and error, I discovered that removing the prefixes from the ID column names in the lookup formula (e.g., changing vehicle_id back to id) fixed the issue.

This seems to be a quirk in WeWeb, Supabase, or PostgreSQL, but I wanted to share my experience since I couldn’t find this solution online. Hopefully, it helps anyone encountering a similar issue.

As for why I renamed the IDs in the first place, I misunderstood some documentation and thought making column names unique would prevent future problems. Turns out that in this case, it caused one!

Has anyone else encountered this? I’d love to hear if there’s a better way to handle this or if it’s just a bug.

2 posts - 2 participants

Read full topic