-
Notifications
You must be signed in to change notification settings - Fork 574
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
Database triggers #4860
Open
dieriba
wants to merge
57
commits into
main
Choose a base branch
from
database_triggers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,321
−429
Open
Database triggers #4860
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
6315ace
feat: init database triggers
dieriba 3a41d0c
Merge branch 'main' into database_triggers
dieriba aa298c8
feat: :sparkles: wip: database_triggers
dieriba 80cc8e0
feat: :sparkles: add database triggers front view
dieriba 3e367e4
feat: :construction: database_triggers
dieriba c70ca15
feat: :construction: add definition in yaml, updated backend code and…
dieriba 68c3a3c
feat: :construction: updated migration file, update openapi.yml, upda…
dieriba bc3e19b
fix: struct rust
dieriba 9a1ad78
feat: :construction: update migrate, database trigger backend functio…
dieriba fa456db
feat: :construction: add resource picker front, update backend function
dieriba cdb272c
feat: :construction: edit inner database inner, update triggers
dieriba 3cdf0a2
feat: :construction: database_triggers
dieriba fabe469
feat: :construction: update openapi yaml, prettied websocker trigger
dieriba 64e9938
feat: :construction: database_triggers
dieriba cdfad9c
feat: :construction: add resource module, update variable file, worki…
dieriba 378b3ed
feat: :bug: working sqlx query
dieriba 7300370
feat: :construction: fix query with sqlx, added main loop
dieriba 9751ffe
feat: :construction: add new column database_trigg
dieriba 939e4a1
feat: :passport_control: run jobs works
dieriba 716c18e
feat: :construction: handling slot name and replication
dieriba 8b8a3e7
feat: restructring triggers, decoding trigger message on work
dieriba a864b03
feat: :construction: database_trigger
dieriba 18b96cc
feat: :construction:
dieriba 23d942c
feat: :construction: converter done, work on custom script
dieriba da4264e
feat: :construction: multiple trigger
dieriba 51c807a
feat: :construction: adding new argument function
dieriba 0928c8e
feat: :construction: database_trigger
dieriba f8814a1
feat: :construction: add generate template for front, update script p…
dieriba e41965a
feat: :construction: template script fix bug, work on restructing bac…
dieriba 0215d5a
feat: :construction: update autogenerated script, add persistence sta…
dieriba d85e25f
feat: :construction: update structure client
dieriba 5813063
feat: :construction: rewrited crud function
dieriba 86877af
feat: :construction: added publication handler
dieriba 69dcf6d
feat: :construction: new ui finished
dieriba c0f624a
feat: :construction: added slot function hanlder finish front ux
dieriba c1b5c6d
feat: :sparkles: ux improvement done, backend logic done
dieriba 351a6b7
feat: :bug: fix where clause
dieriba 7cb0b6c
Merge branch 'main' into database_triggers
dieriba 348922d
feat:
dieriba 7011cda
feat:
dieriba e431b28
chore: update .sqlx and remove empty package
dieriba 8d46b20
Merge branch 'main' into database_triggers
dieriba c30d032
fix: update publication and remove unneccessary print
dieriba f85ec3f
feat: finish converter to json, remove save button, remove unused crate
dieriba 01b6ff3
feat: update migration for database trigger, fixed query, fixed front…
dieriba 230034b
chore: update .sqlx
dieriba a0ca315
Merge branch 'main' into database_triggers
dieriba eaf47f5
chore: update sqlx
dieriba da30536
chore: .sqlx
dieriba 66e305d
chore: add unused
dieriba 681f193
Merge branch 'main' into database_triggers
dieriba 4c05214
fix: use right database resource in back and front
dieriba d183b59
Merge branch 'main' into database_triggers
dieriba b44263c
fix build
HugoCasa c26c0f8
Merge remote-tracking branch 'origin/main' into database_triggers
HugoCasa 81d3ec8
refactor:
dieriba beed5fd
fix sqlx
HugoCasa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ use std::{collections::HashMap, pin::Pin}; | |
|
||
use crate::{ | ||
database_triggers::{ | ||
handler::get_database_resource, | ||
relation::RelationConverter, | ||
replication_message::{ | ||
LogicalReplicationMessage::{Begin, Commit, Delete, Insert, Relation, Type, Update}, | ||
|
@@ -19,7 +18,7 @@ use pg_escape::{quote_identifier, quote_literal}; | |
use rand::seq::SliceRandom; | ||
use rust_postgres::{Client, Config, CopyBothDuplex, NoTls, SimpleQueryMessage}; | ||
use serde_json::to_value; | ||
use windmill_common::{worker::to_raw_value, INSTANCE_NAME}; | ||
use windmill_common::{variables::get_variable_or_self, worker::to_raw_value, INSTANCE_NAME}; | ||
|
||
use super::{ | ||
handler::{Database, DatabaseTrigger}, | ||
|
@@ -210,13 +209,32 @@ async fn listen_to_transactions( | |
db: DB, | ||
mut killpill_rx: tokio::sync::broadcast::Receiver<()>, | ||
) -> Result<(), Error> { | ||
let resource = get_database_resource( | ||
&db, | ||
let resource = sqlx::query_scalar!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should also use get_resource_value_interpolated here. You can use fetch_api_authed with the trigger editor/email fields |
||
"SELECT value from resource WHERE path = $1 AND workspace_id = $2", | ||
&database_trigger.database_resource_path, | ||
&database_trigger.workspace_id, | ||
&database_trigger.workspace_id | ||
) | ||
.fetch_optional(&db) | ||
.await | ||
.map_err(Error::Common)?; | ||
.map_err(|e| Error::Common(windmill_common::error::Error::SqlErr(e)))? | ||
.flatten(); | ||
|
||
let mut resource = match resource { | ||
Some(resource) => serde_json::from_value::<Database>(resource) | ||
.map_err(|e| Error::Common(windmill_common::error::Error::SerdeJson(e)))?, | ||
None => { | ||
return { | ||
Err(Error::Common(windmill_common::error::Error::NotFound( | ||
"Database resource do not exist".to_string(), | ||
))) | ||
} | ||
} | ||
}; | ||
|
||
resource.password = | ||
get_variable_or_self(resource.password, &db, &database_trigger.workspace_id) | ||
.await | ||
.map_err(Error::Common)?; | ||
|
||
let client = PostgresSimpleClient::new(&resource).await?; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're missing auth for a bunch of these APIs
also you should use authed to get the resource with get_resource_value_interpolated_internal