Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected white space inclusion in signature (Pg error: function ... does not exist) #129

Closed
DiegoAlpizar opened this issue May 21, 2024 · 1 comment · Fixed by #130
Closed

Comments

@DiegoAlpizar
Copy link

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

@olirice
Copy link
Owner

olirice commented May 21, 2024

thanks, resolved in #130

its available on pypi under version 0.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants