Pycharm displays Stored Procedures as Functions

已回答

When adding SQL stored procedures in PyCharm, the icon display in the "Structure" Tool window is correct ( A pink circle with a P ), but the database tool window shows stored procedures and function as Functions ( A pink circle with an "F").

Problem 1

If we try to drop the procedure from the Database tool window by right clicking and selecting drop, the generated code is for a "Function" and works only if   "function" is changed to "procedure". This becomes a problem if we SHIFT SELECT multiple SProcs and right click and choose drop.

 

It would have been great if pycharm could display stored procedures and Functions display as separate database objects just like in pgAdmin4.

Problem 2

Display the parameter name along with its datatype for SProcs & Functions just like it displays in pgAdmin4.

Is there a setting to fix this ?

 

0

Could you please share a source code for this object from pgAdmin?

If you double-click on function in DataGrip you will see source code - will there be "create function" or "create procedure"? 

0

What I wrote:

CREATE OR REPLACE PROCEDURE article_add
(
article_title TEXT
, article_txt TEXT
, commit_message TEXT = 'New Article'
)
AS $$
DECLARE
article_exists text;
new_id int4;
BEGIN
-- Check if Article Title Exists
SELECT article.title INTO article_exists FROM "article"
WHERE lower(article.title) = lower(article_title);
IF article_exists IS NOT NULL THEN
RAISE EXCEPTION 'Article with title `%` Exists', article_title;
END IF;


INSERT INTO article(title, body)
VALUES(article_title, article_txt);

new_id := currval('article_article_id_seq');
RAISE NOTICE 'Added Article, id: %, title: `%`', new_id, article_title;
END
$$
LANGUAGE 'plpgsql';

 

 

Double clicking the `routine` in the Database Tool window in Pycharm yields this:

 

From pgAdmin

0

Can't reproduce the issue. Just checked with PG11 and 12 and everywhere the procedure from your code creates as procedure and is shown as P. Could you please make a screencast of this behavior?

0

请先登录再写评论。