Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesFastAPI ProductionModule 6 · Real-World PatternsMulti-tenancy: row-level + Postgres RLSwrite99 / 105
+150 XP
Task
📝 **Task:** Implement `tenant_filter(rows, tenant_id)` returning only rows whose `tenant_id` matches. Then implement `audit_leaks(rows, tenant_id)` that returns the count of rows belonging to OTHER tenants — non-zero means a query forgot its filter. Print 4 results: filtered ids of t1, count of leaks-for-t1, filtered ids for t2, and audit on an already-clean list. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if stuck.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…