supabase/postgres-meta

Duplicated triggers in one schema.

Closed this issue · 4 comments

Bug report

Describe the bug

There is a bug in UI Side (not functionally) that duplicated triggers in one schema, though the triggers were created to different schemas.

To Reproduce

  1. Go to Supabase Dashboard.
  2. Create 2 functions with same name, but pointed to 2 different schemas.
  3. Create 2 triggers from the previous functions respectively.
  4. Refresh the page.
  5. Found that both functions classified as only of the schemas, in the UI.

Expected behavior

There shouldn't be a bug that show duplicated trigger in the same schema, while actually they live in different schemas.

Screenshots & Video

Screenshot 2023-01-15 at 00 41 35

Screenshot 2023-01-15 at 00 41 23

screen-recording-2023-01-15-at-005313_chsi9Whs.mp4

System information

  • OS : MacOS
  • Browser : Safari

though the trigger lives in schema test, I'm unable to add a trigger for schema public.

Screenshot 2023-01-15 at 20 53 39

Hey @anggoran, its been a while since this issue was reported, are you still experiencing this issue?

@KevinBrolly I experienced this issue today. Same scenario. I created triggers with the same name in two different schemes. This worked, but there are indistinguishable duplicate entries in the Database Triggers Page.

Haven't testet if they work correctly yet, but I guess its just a UI issue.

this is really interesting - it's potentially an issue in postgres-meta, but yes just a appearance issue nothing broken functionally, gonna shift the issue there cc @soedirgo

to repeat the reproducible steps via the dashboard (as OP's message as a few details missing)

  • Ensure you have at least 2 schemas (e.g public, test_schema)
  • Create a table with the same name on each schema
    • e.g CREATE TABLE public.countries ... and CREATE TABLE test_schema.countries...
  • Create a function that returns a trigger with the same name on each schema
    • e.g CREATE FUNCTION public.test_fn ... and CREATE FUNCTION test_schema.test_fn
  • Now create a trigger with the same name, on the table with the function from the same schema
    • e.g Trigger 1: Named "test_trigger" on public.countries, with public.test_fn
    • e.g Trigger 2: Named "test_trigger" on test_schema.countries with test_schema.test_fn

Thereafter, if you check the GET triggers pg meta request, the endpoint returns an incorrect payload as such:
Notice entries with the same ID, but different schema and function_schema

[
    {
        "id": 29872,
        "table_id": 28612,
        "enabled_mode": "ORIGIN",
        "function_args": [],
        "name": "test",
        "table": "countries",
        "schema": "test_schema",
        "condition": null,
        "orientation": "STATEMENT",
        "activation": "BEFORE",
        "events": [
            "INSERT"
        ],
        "function_name": "test_fn",
        "function_schema": "public"
    },
    {
        "id": 29872,
        "table_id": 28612,
        "enabled_mode": "ORIGIN",
        "function_args": [],
        "name": "test",
        "table": "countries",
        "schema": "public",
        "condition": null,
        "orientation": "STATEMENT",
        "activation": "BEFORE",
        "events": [
            "INSERT"
        ],
        "function_name": "test_fn",
        "function_schema": "public"
    },
    {
        "id": 29873,
        "table_id": 29844,
        "enabled_mode": "ORIGIN",
        "function_args": [],
        "name": "test",
        "table": "countries",
        "schema": "test_schema",
        "condition": null,
        "orientation": "STATEMENT",
        "activation": "BEFORE",
        "events": [
            "INSERT"
        ],
        "function_name": "test_fn",
        "function_schema": "test_schema"
    },
    {
        "id": 29873,
        "table_id": 29844,
        "enabled_mode": "ORIGIN",
        "function_args": [],
        "name": "test",
        "table": "countries",
        "schema": "public",
        "condition": null,
        "orientation": "STATEMENT",
        "activation": "BEFORE",
        "events": [
            "INSERT"
        ],
        "function_name": "test_fn",
        "function_schema": "test_schema"
    }
]