From 7166409c75d6201780e9dcc4423ff98b387bf998 Mon Sep 17 00:00:00 2001 From: Chareice Date: Tue, 12 Dec 2023 09:58:14 +0800 Subject: [PATCH] fix: quote ident in postgres get table definition --- .../database/src/query-interface/postgres-query-interface.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/database/src/query-interface/postgres-query-interface.ts b/packages/core/database/src/query-interface/postgres-query-interface.ts index 6e920e8284..f900fd7b12 100644 --- a/packages/core/database/src/query-interface/postgres-query-interface.ts +++ b/packages/core/database/src/query-interface/postgres-query-interface.ts @@ -118,11 +118,11 @@ export default class PostgresQueryInterface extends QueryInterface { CREATE OR REPLACE FUNCTION show_create_table(p_schema text, p_table_name text) RETURNS text AS $BODY$ -SELECT 'CREATE TABLE ' || p_schema || '.' || p_table_name || ' (' || E'\\n' || '' || +SELECT 'CREATE TABLE ' || quote_ident(p_schema) || '.' || quote_ident(p_table_name) || ' (' || E'\\n' || '' || string_agg(column_list.column_expr, ', ' || E'\\n' || '') || '' || E'\\n' || ');' FROM ( - SELECT ' ' || column_name || ' ' || data_type || + SELECT ' ' || quote_ident(column_name) || ' ' || data_type || coalesce('(' || character_maximum_length || ')', '') || case when is_nullable = 'YES' then '' else ' NOT NULL' end as column_expr FROM information_schema.columns