pgadmin-org / pgadmin4

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
https://www.pgadmin.org
Other
2.46k stars 646 forks source link

Schema Diff: Issue when trigger names are same but trigger function body is different #5762

Closed kblum007 closed 4 months ago

kblum007 commented 1 year ago

When comparing two tables that:

Schema Diff reports the two tables are different, and the script generator simply recreates the trigger (see generated_script_ddl.txt) with no reference or action to the trigger function.

I understand from the documentation that Schema Diff does not resolve dependencies. However, the behavior, in this case, is inconsistent. Schema Diff seems to understand that the trigger functions are different, but -- The DDL comparison for the source and target are identical -- The difference/generated script doesn't address the actual solution

source_ddl.txt target_ddl.txt trigger_definition.txt source_trigger_dll.txt target_trigger_dll.txt generated_script_ddl.txt

akshay-joshi commented 1 year ago

@kblum007

You seem to compare two schemas in your case, which is 'cmdb', which contains both tables and triggers. Your trigger function is in a different schema that is not included in the comparison, so this behavior is expected, but we will investigate.

Schema diff resolves dependencies between schemas. Create a trigger_function in 'cmdb', and it will be selected automatically when the table object is selected.

Meanwhile, you can compare the whole database, schema diff will show the trigeer_function that you can select and generate the scripts.

kblum007 commented 1 year ago

I understand the different schemas. It’s that if Schema Diff is only looking at the current schema’s objects then why is it presenting the objects as “different” when the only thing that is different about them is the trigger function in another schema? It’s inconsistent with the expected behavior.

From: Akshay Joshi @.> Sent: Friday, January 20, 2023 7:25 AM To: pgadmin-org/pgadmin4 @.> Cc: Blum, Kimber @.>; Mention @.> Subject: Re: [pgadmin-org/pgadmin4] Schema Diff: Issue when trigger names are same but trigger function body is different (Issue #5762)

@kblum007https://urldefense.com/v3/__https:/github.com/kblum007__;!!DZ3fjg!9nkWKG3hOQGipV-qg_lh3O7YnH1MOAk7Mu1z7As2PYPbisevhikU3wqfWxtLKLLaf_yQjb3SPX0eEmnm_WGiuzWjbjU$

You seem to compare two schemas in your case, which is 'cmdb', which contains both tables and triggers. Your trigger function is in a different schema that is not included in the comparison, so this behavior is expected, but we will investigate.

Schema diff resolves dependencies between schemas. Create a trigger_function in 'cmdb', and it will be selected automatically when the table object is selected.

Meanwhile, you can compare the whole database, schema diff will show the trigeer_function that you can select and generate the scripts.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/pgadmin-org/pgadmin4/issues/5762*issuecomment-1398381666__;Iw!!DZ3fjg!9nkWKG3hOQGipV-qg_lh3O7YnH1MOAk7Mu1z7As2PYPbisevhikU3wqfWxtLKLLaf_yQjb3SPX0eEmnm_WGimZNSusQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AIRACZ4VCAVFQESB6II22HTWTKG3XANCNFSM6AAAAAAUASPFWA__;!!DZ3fjg!9nkWKG3hOQGipV-qg_lh3O7YnH1MOAk7Mu1z7As2PYPbisevhikU3wqfWxtLKLLaf_yQjb3SPX0eEmnm_WGi0XfnJb4$. You are receiving this because you were mentioned.Message ID: @.**@.>>

pravesh-sharma commented 4 months ago

Issue fixed. Verified on snapshot build.

Env: OS - macOS Sonoma 14.4.1 Mode - Desktop