Skip to content

Perpetual policy diffs: table references not normalized #224

@asonawalla

Description

@asonawalla

Summary

Following the fix in PR #222 for function qualifier normalization (issue #220), we're still seeing perpetual diffs when policy expressions reference tables with same-schema qualifiers.

Context

PR #222 correctly normalizes function calls like public.auth_uid()auth_uid(). However, the same issue exists for table references within policy expressions.

Reproduction

Schema file contains:

CREATE POLICY "Select own orders" ON orders
FOR SELECT TO authenticated
USING (user_id IN (
    SELECT u.id
    FROM users u  -- no public. prefix
    WHERE u.tenant_id = (SELECT public.current_tenant_id())
));

pgschema generates DDL with:

FROM public.users u  -- adds public. prefix

But PostgreSQL's pg_get_expr() returns:

FROM users u  -- no public. prefix

This creates a perpetual diff where pgschema always wants to ALTER the policy.

Expected Behavior

Table references within policy expressions should be normalized the same way function calls are in PR #222—strip same-schema qualifiers during comparison.

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions