postgresql DBeaver将过程中的属性列表转换为字符串

lxkprmvk  于 2024-01-07  发布在  PostgreSQL
关注(0)|答案(1)|浏览(163)

我试图通过换行符来写属性,以使过程易于阅读和编辑,但是,在保存过程之后,dbeaver会自动编辑它,将过程中的属性列表转换为字符串。
这是我自己写的一个程序头:

CREATE OR REPLACE PROCEDURE public.full_load(
    IN input_table_name VARCHAR, 
    IN target_table_name VARCHAR, 
    IN load_key_field VARCHAR, 
    IN load_id_field VARCHAR, 
    IN last_load_id_field VARCHAR, 
    IN valid_to_dttm_field VARCHAR, 
    IN valid_from_dttm_field VARCHAR, 
    IN paral INT DEFAULT 1
)

字符串
这是DBeaver在保存后自动编辑我的程序的方式:

CREATE OR REPLACE PROCEDURE public.full_load(IN input_table_name character varying, IN target_table_name character varying, IN load_key_field character varying, IN load_id_field character varying, IN last_load_id_field character varying, IN valid_to_dttm_field character varying, IN valid_from_dttm_field character varying, IN paral integer DEFAULT 1)


它使我的代码更难阅读和编辑。
Dbeaver设置中是否有一个参数负责禁用程序标题的自动编辑?

jogvjijk

jogvjijk1#

当你检查你在db上定义的一个例程时,DBeaver可能只是运行pg_get_function_arguments()。它不会 * 回忆 * 例程是如何精确定义的,直到注解和空格,而是 * 重建 * 一个兼容DDL的列表:
pg_get_function_arguments (funcoid ) → text
重新构造函数或过程的参数列表,以它在CREATE FUNCTION中需要出现的形式(包括默认值)。
你可以自己试试:

CREATE OR REPLACE PROCEDURE /*inline comment*/ public.full_load    (
    IN input_table_name VARCHAR, --end-of-line comment
     IN target_table_name VARCHAR,
    IN load_key_field VARCHAR,
    IN load_id_field VARCHAR,
    IN last_load_id_field VARCHAR,
    IN valid_to_dttm_field VARCHAR,
    IN valid_from_dttm_field VARCHAR,
      IN paral INT DEFAULT 1
) LaNguAge PlpgSql as --funky capitalization
$$
bEGin SeLeCT 'abc'/*inline*/           ;
eND; --end of line comment
$$;

select pg_get_function_arguments('full_load'::regproc);

字符串
| pg获取函数参数|
| --|
| IN input_table_name字符变化,IN target_table_name字符变化,IN load_key_field字符变化,IN load_id_field字符变化,IN last_load_id_field字符变化,IN valid_to_dttm_field字符变化,IN valid_from_dttm_field字符变化,IN paral integer DEFAULT 1|
您还可以在psql元命令\ef full_load中看到这一点:body按原样保存并全部调用,而其余部分仅重建:

CREATE OR REPLACE PROCEDURE public.full_load(IN input_table_name character varying, IN target_table_name character varying, IN load_key_field character varying, IN load_id_field character varying, IN last_load_id_field character varying, IN valid_to_dttm_field character varying, IN valid_from_dttm_field character varying, IN paral integer DEFAULT 1)
 LANGUAGE plpgsql
AS $procedure$
bEGin SeLeCT 'abc'/*inline*/           ;
eND; --end of line comment
$procedure$


如果你想保留这样的细节,你应该保存你的代码作为.sql脚本文件somewhere。否则,PostgreSQL将只尝试记住例程主体的细节,但是签名(名称,参数,设置)将从无关紧要的标记中剥离,比如注解和空白,包括你丢失的换行符和缩进,加上大写。

相关问题