cweijan / vscode-database-client

Database Client For Visual Studio Code
https://database-client.com
MIT License
2.39k stars 264 forks source link

PostgreSQL - Include Triggers in Table DDL #1170

Closed onwardmk closed 3 weeks ago

onwardmk commented 3 weeks ago

The extension currently doesn't display table triggers.

It would be nice if:

cweijan commented 3 weeks ago

You can set the show triggers, after version 7.4.5, the DDL will include the triggers.

image

onwardmk commented 3 weeks ago

Thank you!

It's working, but I see an issue with this feature. The trigger definition is duplicated 3 times in both the tree view and the DDL when I right-click on the table and select "Show Table DDL."

image
cweijan commented 3 weeks ago

Try executing this SQL. This is the SQL for the extension to get the trigger.

SELECT TRIGGER_NAME "TRIGGER_NAME" FROM information_schema.TRIGGERS 
    WHERE trigger_schema = 'public' AND event_object_table='table_name' ORDER BY TRIGGER_NAME ASC
onwardmk commented 3 weeks ago

Try executing this SQL. This is the SQL for the extension to get the trigger.

SELECT TRIGGER_NAME "TRIGGER_NAME" FROM information_schema.TRIGGERS 
    WHERE trigger_schema = 'public' AND event_object_table='table_name' ORDER BY TRIGGER_NAME ASC

Ah okay, I wasn't aware that PostgreSQL defines a trigger per event type (INSERT, UPDATE, DELETE). I'm more familiar with MS-SQL, where you define a single trigger for all event types. Thanks again.

cweijan commented 3 weeks ago

Hi, after investigation, there is actually only one trigger. I will perform deduplication in the next version.