From e0bd9fd8c1c53ea5dd20c6e25913d4c5a73173a6 Mon Sep 17 00:00:00 2001 From: FindAPattern Date: Sun, 1 Dec 2024 11:37:00 -0500 Subject: [PATCH] Added table schema checks to linearite demo triggers. I ran into an issue using these triggers on a table with the same name as a table in another schema. Adding table schema checks fixes the issue. --- demos/linearlite/db/migrations-client/01-create_tables.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demos/linearlite/db/migrations-client/01-create_tables.sql b/demos/linearlite/db/migrations-client/01-create_tables.sql index d1f9e70e..3d8d08e0 100644 --- a/demos/linearlite/db/migrations-client/01-create_tables.sql +++ b/demos/linearlite/db/migrations-client/01-create_tables.sql @@ -138,6 +138,7 @@ BEGIN FOR col_name IN SELECT column_name FROM information_schema.columns WHERE table_name = TG_TABLE_NAME AND + table_schema = TG_TABLE_SCHEMA AND column_name NOT IN ('id', 'synced', 'modified_columns', 'backup', 'deleted', 'new', 'sent_to_server', 'search_vector') LOOP EXECUTE format('SELECT $1.%I', col_name) USING NEW INTO new_value; EXECUTE format('SELECT %I FROM %I WHERE id = $1', col_name, TG_TABLE_NAME) USING NEW.id INTO old_value; @@ -223,6 +224,7 @@ BEGIN FOR column_name IN SELECT columns.column_name FROM information_schema.columns WHERE columns.table_name = TG_TABLE_NAME + AND columns.table_schema = TG_TABLE_SCHEMA AND columns.column_name NOT IN ('id', 'synced', 'modified_columns', 'backup', 'deleted', 'new', 'sent_to_server', 'search_vector') LOOP IF column_name != ANY(OLD.modified_columns) THEN EXECUTE format('SELECT ($1).%I', column_name) USING NEW INTO new_value; @@ -240,6 +242,7 @@ BEGIN FOR column_name IN SELECT columns.column_name FROM information_schema.columns WHERE columns.table_name = TG_TABLE_NAME + AND columns.table_schema = TG_TABLE_SCHEMA AND columns.column_name NOT IN ('id', 'synced', 'modified_columns', 'backup', 'deleted', 'new', 'sent_to_server', 'search_vector') LOOP EXECUTE format('SELECT ($1).%I', column_name) USING NEW INTO new_value; EXECUTE format('SELECT ($1).%I', column_name) USING OLD INTO old_value;