-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Postgresql's function and trigger #403
Comments
Hey @HigherOrderLogic, thanks for the feature request! I think creating, dropping and altering of function and trigger can be offered under |
I'll open this for contributions! :) |
@billy1624 @tyt2y3 do we really want to add support for this functionality? |
If you are open to contribution for this issue, then I'd like to work on it |
Hey @anshulxyz, this is still open for contribution! Please go ahead :D |
@billy1624 I'm not sure whether @anshulxyz is still working on this issue or not but I'm going to start working to add support for the |
@stevenhansel I'm not, you can take over the issue. |
Thanks!! @stevenhansel Let me know if you need any help :) |
Do you have any idea about the API design in mind? |
Hey @HigherOrderLogic, you can take this as a reference TypeCreateStatement. We need to create a struct let say I imagine the API be like... enum Event {
Insert,
Update(Vec<ColumnRef>),
Delete,
Truncate,
}
Trigger::create()
.or_replace()
.name(NameIden)
.table(TableIden)
// One of the event that fire the trigger
.before_event(Event::Insert)
.after_event(Event::Update(vec![ ... ]))
.instead_of_event(Event::Delete)
// How the trigger function should be fired
.for_each_row()
.for_each_statement()
// Function to execute
.execute_function(Func)
.to_string(PostgresQueryBuilder); |
@HigherOrderLogic I'm mostly thinking the same thing with what @billy1624 wrote, for creating a trigger we can just follow the existing e.g. this is how you would drop a table using seaquery (from the docs) let table = Table::alter()
.table(Font::Table)
.add_column(
ColumnDef::new(Alias::new("new_col"))
.integer()
.not_null()
.default(100),
)
.to_owned(); Well, this is probably a rough counterpart for the Trigger::drop()
.if_exists()
.name(NameIden)
.table(TableIden); |
Hello all, I am willing to contribute on this. May i know if anyone is still working on this? Would love to discuss the details |
Motivation
Give users the ablity to create functions and triggers on database by using
sea-query
instead of raw SQL.Proposed Solutions
N/A
Additional Information
https://www.postgresql.org/docs/current/plpgsql-trigger.html
The text was updated successfully, but these errors were encountered: