(no title)
ericHosick | 6 months ago
```sql FUNCTION debug_user(user_id):
IF NOT (SELECT FROM user WHERE user.user_id = user_id) THEN
-- user doesn’t exist
END IF;
IF NOT (SELECT FROM user
JOIN user_addr ON user_addr.user_id = user.user_id
WHERE user.user_id = user_id) THEN
-- user has no address
END IF;
-- keep adding joins until you find the break
```because when you have a query that involves 6 relations, and you don't get results, it is nice to know why.
FrancoisBosun|6 months ago
ericHosick|6 months ago
these functions can also be exposed in admin ui's making it easier for the general admin users/support users.
another very useful use case is when row level security (RLS) is enabled.
polishdude20|6 months ago
iTokio|6 months ago