File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ ON pg_t.tgrelid = pg_c.oid
2929JOIN information_schema .triggers AS is_t
3030ON is_t .trigger_name = pg_t .tgname
3131AND pg_c .relname = is_t .event_object_table
32- AND pg_c .relnamespace = is_t .event_object_schema ::regnamespace
32+ AND pg_c .relnamespace = (quote_ident( is_t .event_object_schema )) ::regnamespace
3333JOIN pg_proc AS pg_p
3434ON pg_t .tgfoid = pg_p .oid
3535JOIN pg_namespace AS pg_n
Original file line number Diff line number Diff line change @@ -264,3 +264,51 @@ create schema s2; create table s2.t(); create trigger tr before insert on s2.t e
264264
265265 await pgMeta . query ( 'drop schema s1 cascade; drop schema s2 cascade;' )
266266} )
267+
268+ test ( 'triggers on capitalized schema and table names' , async ( ) => {
269+ await pgMeta . query ( `
270+ CREATE SCHEMA "MySchema";
271+ CREATE TABLE "MySchema"."MyTable" (
272+ id SERIAL PRIMARY KEY,
273+ name TEXT NOT NULL,
274+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
275+ updated_at TIMESTAMP
276+ );
277+ CREATE OR REPLACE FUNCTION "MySchema"."my_trigger_function"()
278+ RETURNS TRIGGER AS $$
279+ BEGIN
280+ NEW.updated_at := CURRENT_TIMESTAMP;
281+ RETURN NEW;
282+ END;
283+ $$ LANGUAGE plpgsql;
284+
285+ CREATE TRIGGER "my_trigger"
286+ BEFORE INSERT ON "MySchema"."MyTable"
287+ FOR EACH ROW
288+ EXECUTE FUNCTION "MySchema"."my_trigger_function"();
289+ ` )
290+
291+ const res = await pgMeta . triggers . list ( )
292+ const triggers = res . data ?. map ( ( { id, table_id, ...trigger } ) => trigger )
293+ expect ( triggers ) . toMatchInlineSnapshot ( `
294+ [
295+ {
296+ "activation": "BEFORE",
297+ "condition": null,
298+ "enabled_mode": "ORIGIN",
299+ "events": [
300+ "INSERT",
301+ ],
302+ "function_args": [],
303+ "function_name": "my_trigger_function",
304+ "function_schema": "MySchema",
305+ "name": "my_trigger",
306+ "orientation": "ROW",
307+ "schema": "MySchema",
308+ "table": "MyTable",
309+ },
310+ ]
311+ ` )
312+
313+ await pgMeta . query ( 'drop schema "MySchema" cascade;' )
314+ } )
You can’t perform that action at this time.
0 commit comments