File tree 2 files changed +49
-1
lines changed
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
29
29
JOIN information_schema .triggers AS is_t
30
30
ON is_t .trigger_name = pg_t .tgname
31
31
AND 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
33
33
JOIN pg_proc AS pg_p
34
34
ON pg_t .tgfoid = pg_p .oid
35
35
JOIN 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
264
264
265
265
await pgMeta . query ( 'drop schema s1 cascade; drop schema s2 cascade;' )
266
266
} )
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