Closed veledzimovich-iTechArt closed 5 months ago
language
and returns
are both already available, unless i'm missing a particular aspect of your question.
security definer
at least seems straightforward to add. almost certainly security=FunctionSecurity.defineer
and/or function.security_definer()
I'd appreciate it if you could test the PR out ahead of my merging it, to make sure it does what you're anticipating it do.
Thank you.
Everything generated correctly.
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute(
"""CREATE FUNCTION refresh_my_view() RETURNS void SECURITY DEFINER LANGUAGE plpgsql AS $$
BEGIN
REFRESH MATERIALIZED VIEW my_view WITH DATA;
END
$$;"""
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute("""DROP FUNCTION refresh_my_view();""")
# ### end Alembic commands ###
alembic revision --autogenerate
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute(
"""CREATE OR REPLACE FUNCTION refresh_my_view() RETURNS void SECURITY DEFINER LANGUAGE plpgsql AS $$
BEGIN
REFRESH MATERIALIZED VIEW my_view WITH DATA;
END
$$;"""
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute(
"""CREATE OR REPLACE FUNCTION refresh_my_view() RETURNS void LANGUAGE plpgsql AS $$
BEGIN
REFRESH MATERIALIZED VIEW my_view WITH DATA;
END
$$;"""
)
# ### end Alembic commands ###
alembic revision check
.
As expected, I received an error.
It would be nice to have the possibility to provide the
SECURITY DEFINER
directive as a field to the sqlalchemy_declarative_extensions.dialects.postgresql.Function, along withlanguage
orreturns
fields.Because right now, we have to add it manually in our migration scripts.