Just use Row-Level Security. It's available in Postgres and in MS SQL Server already. It's much safer because it's on DB level.