[BUG] Regression in v1.8.0: Function Calls Broken in RLS Policies
Hi, first of all thanks for the great work on pgschema.
I ran into an issue after upgrading from v1.7.4 to v1.8.0 related to RLS policies. It looks like function calls inside CREATE POLICY / ALTER POLICY are getting mangled in the generated migration plan.
What’s happening
In v1.8.0, function calls are not preserved correctly. The generator seems to:
- Break the function call syntax by stripping parentheses
- Merge parts into an invalid token
Because of this, the generated SQL ends up referencing a function that doesn’t exist.
Example
Input schema:
p.id IN (
SELECT unnest(get_user_assigned_projects()) AS unnest
)
Generated plan (v1.8.0):
p.id IN (
SELECT unnestget_user_assigned_projects() AS unnest
)
As you can see, unnest(get_user_assigned_projects()) turns into unnestget_user_assigned_projects().
Error when applying
ERROR: function unnestget_user_assigned_projects() does not exist (SQLSTATE 42883)
Expected behavior
The function call should be preserved exactly as defined:
SELECT unnest(get_user_assigned_projects()) AS unnest
Notes
- This worked correctly in v1.7.4
- Issue appears in policy
USINGexpressions (CREATE/ALTER POLICY) - Likely related to how expressions are parsed or rewritten in v1.8.0
Environment
- Broken version:
1.8.0 - Working version:
1.7.4 - PostgreSQL:
17 - OS: macOS (Apple Silicon)
Happy to provide any additional context or test cases if that would help. Thank you for looking into this!