Linebreaks and comments are not preserved for RLS policies #16922
tanius
started this conversation in
Contribute to Supabase
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug report
Describe the bug
When creating a RLS policy using the supabase.com Studio UI, you can add comments
/* … */
and indentation for clarity. But after saving the RLS policy, both are removed. When opening it again to edit it, indentation has been replaced by auto-generated indentation that is hard to read for more complex RLS policies (say, involving joins). In addition, many pairs of auto-generated parentheses have been added that also make the code harder to read.Example for a CHECK expression as I entered it into the RLS policy dialog:
And this is how the same expression looks after saving and re-opening the editor:
(The same issue could be raised for VIEWs, but that has to wait until Studio UI adds support for creating them. So far, it's rather a PostgreSQL issue, as PostgreSQL itself does not preserve the original code used to create VIEWs.)
Expected behavior
Both comments and indentation should be preserved. If it is not possible to preserve indentation, the auto-indentation algorithm should be improved.
As for VIEWs, where PostgreSQL does not preserve the original code used to create the view, this is seemingly intended behavior on the side of PostgreSQL and unlikely to change. In a discussion on the PostgreSQL mailing list, it has been recommended for such a case to use an external IDE tool to preserve the code in its original form. Now Studio UI seems to aspire to be such an IDE; so I think there's room to argue that it should keep a copy of the original source code used to create the view, or in the scope of this issue report, the RLS policy.
System information
Using the software version on app.supabase.com as of today.
Additional context
As a workaround, you can move all the RLS code to a function. For functions, both comments and custom indentation are preserved.
Beta Was this translation helpful? Give feedback.
All reactions