I tried to create a function like the following, with a space between the name and the opening paren:
delete_post = PGFunction( schema = 'public'
, signature = "delete_post (_id INT , _user_id INT)"
, definition = """
RETURNS posts AS
$BODY$
DECLARE
deleted_post posts%ROWTYPE ;
BEGIN
DELETE
FROM posts
WHERE id = _id
RETURNING *
INTO STRICT deleted_post
;
IF deleted_post.user_id != _user_id
THEN
RAISE 'User ID --> % is not the owner of post ID --> %' , _user_id , _id ;
END IF ;
RETURN deleted_post ;
EXCEPTION
WHEN NO_DATA_FOUND THEN RAISE NO_DATA_FOUND USING MESSAGE = 'Nonexistent post ID --> %' || _id ;
END ;
$BODY$
LANGUAGE plpgsql ;
"""
)
As you can see in alembic upgrade --sql head output, it is actually taking the space as part of the name:
(...)
CREATE FUNCTION "public"."delete_post "(_id INT , _user_id INT) RETURNS posts AS
(...)
So naturally, Postgre was giving me "error it doesn't" exist when trying to invoke the function with the original name
I tried to create a function like the following, with a space between the name and the opening paren:
As you can see in
alembic upgrade --sql head
output, it is actually taking the space as part of the name:So naturally, Postgre was giving me "error it doesn't" exist when trying to invoke the function with the original name