Fixed an issue where the semicolon is misplaced in RLS Policy SQL.

Fixed one regression issue introduced by renaming the method 'gc' to 'gc_timeout'.
This commit is contained in:
Akshay Joshi 2020-06-26 19:24:54 +05:30
parent 115657a465
commit b91f6f0f5c
6 changed files with 18 additions and 14 deletions

View File

@ -5,6 +5,5 @@
CREATE POLICY policy_1 CREATE POLICY policy_1
ON public.test_rls_policy ON public.test_rls_policy
FOR ALL FOR ALL
TO public TO public;
;

View File

@ -5,6 +5,5 @@
CREATE POLICY insert_policy CREATE POLICY insert_policy
ON public.test_rls_policy ON public.test_rls_policy
FOR INSERT FOR INSERT
TO public TO public;
;

View File

@ -5,6 +5,5 @@
CREATE POLICY test CREATE POLICY test
ON public.test_rls_policy ON public.test_rls_policy
FOR ALL FOR ALL
TO public TO public;
;

View File

@ -5,6 +5,5 @@
CREATE POLICY select_policy CREATE POLICY select_policy
ON public.test_rls_policy ON public.test_rls_policy
FOR SELECT FOR SELECT
TO public TO public;
;

View File

@ -2,6 +2,12 @@
-- POLICY: {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }} -- POLICY: {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
-- DROP POLICY {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}; -- DROP POLICY {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }};
{% set add_semicolon_after = 'to' %}
{% if data.withcheck is defined and data.withcheck != None and data.withcheck != '' %}
{% set add_semicolon_after = 'with_check' %}
{% elif data.using is defined and data.using != None and data.using != '' %}
{% set add_semicolon_after = 'using' %}
{% endif %}
CREATE POLICY {{ conn|qtIdent(data.name) }} CREATE POLICY {{ conn|qtIdent(data.name) }}
ON {{conn|qtIdent(data.schema, data.table)}} ON {{conn|qtIdent(data.schema, data.table)}}
@ -9,13 +15,15 @@ CREATE POLICY {{ conn|qtIdent(data.name) }}
FOR {{ data.event|upper }} FOR {{ data.event|upper }}
{% endif %} {% endif %}
{% if data.policyowner %} {% if data.policyowner %}
TO {{ conn|qtTypeIdent(data.policyowner) }} TO {{ conn|qtTypeIdent(data.policyowner) }}{% if add_semicolon_after == 'to' %};{% endif %}
{% else %} {% else %}
TO public TO public{% if add_semicolon_after == 'to' %};{% endif %}
{% endif %} {% endif %}
{% if data.using %} {% if data.using %}
USING ({{ data.using }})
USING ({{ data.using }}){% if add_semicolon_after == 'using' %};{% endif %}
{% endif %} {% endif %}
{% if data.withcheck %} {% if data.withcheck %}
WITH CHECK ({{ data.withcheck }})
{% endif %}; WITH CHECK ({{ data.withcheck }});
{% endif %}

View File

@ -46,4 +46,4 @@ def ping():
drivers = getattr(current_app, '_pgadmin_server_drivers', None) drivers = getattr(current_app, '_pgadmin_server_drivers', None)
for type in drivers: for type in drivers:
drivers[type].gc() drivers[type].gc_timeout()