Skip to content

feat: fix backward compatibility pg 14 for postgres trigger #5851

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0c8076a
remove macro query when interacting with remote db
dieriba May 8, 2025
b3ca9ec
Merge branch 'main' into dieri/fix-backward-compatibility-pg-14-for-p…
dieriba May 8, 2025
5d9c283
fix compatibility and nits
dieriba May 9, 2025
c1ad8fb
Merge branch 'main' into dieri/fix-backward-compatibility-pg-14-for-p…
dieriba May 9, 2025
c212a3a
fix bug save for publication tracking all table
dieriba May 9, 2025
24dcf39
fix infinite loop svelte 5
dieriba May 9, 2025
8c4e301
nits on (gcp/postgres) trigger+ refactor on postgres trigger
dieriba May 9, 2025
2e06438
update .sqlx
dieriba May 9, 2025
7d7c510
update repo ref
dieriba May 9, 2025
f0b37df
uodate repo ref
dieriba May 10, 2025
d818bd8
fix
dieriba May 11, 2025
34a301b
fix
dieriba May 11, 2025
90eb073
nits + extend postgres capture
dieriba May 11, 2025
903564e
fix import gcp
dieriba May 11, 2025
843e56d
Merge branch 'main' into dieri/fix-backward-compatibility-pg-14-for-p…
dieriba May 11, 2025
ae97f28
fix reactivity issue
dieriba May 11, 2025
f39b0a8
add postgres transaction for successive write operation
dieriba May 12, 2025
b7a4cd0
fix isValid state edge cases
dieriba May 12, 2025
8fb7f76
fix reorder transaction
dieriba May 12, 2025
11fc085
reorder transaction
dieriba May 12, 2025
fa01b96
remove unused import
dieriba May 12, 2025
88d4cfa
update test connection
dieriba May 12, 2025
a935d3f
Merge branch 'main' into dieri/fix-backward-compatibility-pg-14-for-p…
dieriba May 24, 2025
bc24bcf
add missing props
dieriba May 24, 2025
35729b0
fix import/bugs and nits
dieriba May 24, 2025
a9fce53
Merge branch 'main' into dieri/fix-backward-compatibility-pg-14-for-p…
dieriba Jun 1, 2025
da0a50a
nits and fix small bugs
dieriba Jun 1, 2025
75c6b37
add missing colon
dieriba Jun 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix import/bugs and nits
  • Loading branch information
dieriba committed May 24, 2025
commit 35729b093e21a94444b3078094a1f3d37e32fce5
18 changes: 13 additions & 5 deletions backend/windmill-api/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use {
http::HeaderMap,
};

#[cfg(any(all(feature = "enterprise", feature = "gcp_trigger"), feature = "postgres_trigger"))]
#[cfg(any(
all(feature = "enterprise", feature = "gcp_trigger"),
feature = "postgres_trigger"
))]
use windmill_common::utils::empty_as_none;

#[cfg(all(feature = "enterprise", feature = "sqs_trigger"))]
Expand All @@ -33,7 +36,14 @@ use windmill_common::auth::aws::AwsAuthResourceType;
feature = "http_trigger",
all(feature = "enterprise", feature = "gcp_trigger")
))]
use {serde::de::DeserializeOwned, windmill_common::error::Error};
use serde::de::DeserializeOwned;

#[cfg(any(
feature = "http_trigger",
feature = "postgres_trigger",
all(feature = "enterprise", feature = "gcp_trigger")
))]
use windmill_common::error::Error;

#[cfg(all(feature = "enterprise", feature = "kafka"))]
use crate::kafka_triggers_ee::KafkaTriggerConfigConnection;
Expand Down Expand Up @@ -361,9 +371,7 @@ async fn set_gcp_trigger_config(
mut capture_config: NewCaptureConfig,
) -> Result<NewCaptureConfig> {
let Some(TriggerConfig::Gcp(mut gcp_config)) = capture_config.trigger_config else {
return Err(windmill_common::error::Error::BadRequest(
"Invalid GCP Pub/Sub config".to_string(),
));
return Err(Error::BadRequest("Invalid GCP Pub/Sub config".to_string()));
};

let config = manage_google_subscription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@
let drawer: Drawer | undefined = $state(undefined)
let is_flow: boolean = $state(false)
let initialPath = $state('')
let edit = $state(true)
let edit: boolean = $state(true)
let itemKind: 'flow' | 'script' = $state('script')
let script_path = $state('')
let initialScriptPath = $state('')
let fixedScriptPath = $state('')
let script_path: string = $state('')
let initialScriptPath: string = $state('')
let fixedScriptPath: string = $state('')
let path: string = $state('')
let pathError = $state('')
let enabled = $state(false)
let dirtyPath = $state(false)
let can_write = $state(true)
let drawerLoading = $state(true)
let showLoading = $state(false)
let postgres_resource_path = $state('')
let enabled: boolean = $state(false)
let dirtyPath: boolean = $state(false)
let can_write: boolean = $state(true)
let drawerLoading: boolean = $state(true)
let showLoading: boolean = $state(false)
let postgres_resource_path: string = $state('')
let publication_name: string = $state('')
let replication_slot_name: string = $state('')
let relations: Relations[] | undefined = $state([])
let transaction_to_track: string[] = $state([])
let language: Language = 'Typescript'
let loading = $state(false)
let postgresVersion = ''
let loadingPostgres = $state(false)
let postgresVersion: string = $state('')
let loadingPostgres: boolean = $state(false)
type actions = 'create' | 'get'
let selectedPublicationAction: actions | undefined = $state(undefined)
let selectedSlotAction: actions | undefined = $state(undefined)
Expand All @@ -103,6 +103,7 @@
let deploymentLoading = $state(false)
let creatingSlot: boolean = $state(false)
let creatingPublication: boolean = $state(false)
let pg14: boolean = $derived(postgresVersion.startsWith('14'))

const errorMessage = $derived.by(() => {
if (relations && relations.length > 0) {
Expand Down Expand Up @@ -134,16 +135,8 @@
const postgresConfig = $derived.by(getSaveCfg)
const captureConfig = $derived.by(isEditor ? getCaptureConfig : () => ({}))

let saveDisabled = $derived(
pathError !== '' ||
emptyString(postgres_resource_path) ||
emptyString(script_path) ||
(isAdvancedTab(tab) && emptyString(replication_slot_name)) ||
emptyString(publication_name) ||
(relations && isBasicTab(tab) && relations.length === 0) ||
transaction_to_track.length === 0 ||
drawerLoading ||
!can_write
const saveDisabled = $derived(
pathError !== '' || emptyString(script_path) || drawerLoading || !can_write || !isValid
)

async function createPublication() {
Expand Down Expand Up @@ -482,8 +475,10 @@
{#snippet content()}
{#if drawerLoading}
{#if showLoading}
<Loader2 size="50" class="animate-spin" />
<p>Loading...</p>
<div class="flex flex-col items-center justify-center h-full w-full">
<Loader2 size="50" class="animate-spin" />
<p>Loading...</p>
</div>
{/if}
{:else}
<div class="flex flex-col gap-4">
Expand Down Expand Up @@ -671,7 +666,7 @@
<svelte:fragment slot="content">
<div class="mt-5 overflow-hidden bg-surface">
<TabContent value="basic">
<RelationPicker {can_write} bind:relations disabled={!can_write} />
<RelationPicker {can_write} bind:pg14 bind:relations disabled={!can_write} />
</TabContent>
<TabContent value="advanced">
<div class="flex flex-col gap-6"
Expand Down Expand Up @@ -780,7 +775,12 @@
disabled={!can_write}
/>
{/if}
<RelationPicker {can_write} bind:relations disabled={!can_write} />
<RelationPicker
bind:pg14
{can_write}
bind:relations
disabled={!can_write}
/>
</div>
</Section></div
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
import Tooltip from '$lib/components/Tooltip.svelte'
import type { Relations } from '$lib/gen'
import { Plus, Trash, X } from 'lucide-svelte'
import MultiSelect from 'svelte-multiselect'
import { getDefaultTableToTrack, invalidRelations } from './utils'
import AddPropertyFormV2 from '$lib/components/schema/AddPropertyFormV2.svelte'
import Label from '$lib/components/Label.svelte'
import { emptyStringTrimmed, sendUserToast } from '$lib/utils'
import MultiSelect from 'svelte-multiselect'

export let relations: Relations[] | undefined = undefined
export let can_write: boolean = true
export let postgresVersion: string = ''
export let disabled: boolean = false

$: pg14 = postgresVersion?.startsWith('14')
export let pg14: boolean = false

$: selected = relations && relations.length > 0 ? 'specific' : 'all'

Expand Down Expand Up @@ -172,23 +170,23 @@
selected={table_to_track.columns_name ?? []}
placeholder="Select columns"
--sms-options-margin="4px"
on:change={(e) => {
const option = e.detail.option?.toString()
onchange={(e) => {
const option = e.option?.toString()
updateRelationsFor(i, (rel) => {
const updatedTables = rel.table_to_track.map((t, idx) => {
if (idx !== j) return t

let updatedColumns = t.columns_name ?? []

if (e.detail.type === 'add' && option) {
if (e.type === 'add' && option) {
updatedColumns = [...updatedColumns, option]
} else if (e.detail.type === 'remove') {
} else if (e.type === 'remove') {
updatedColumns = updatedColumns.filter((col) => col !== option)
} else if (e.detail.type === 'removeAll') {
} else if (e.type === 'removeAll') {
updatedColumns = []
} else {
console.error(
`Priority tags multiselect - unknown event type: '${e.detail.type}'`
`Priority tags multiselect - unknown event type: '${e.type}'`
)
}

Expand Down
14 changes: 7 additions & 7 deletions frontend/src/lib/components/triggers/postgres/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ export async function savePostgresTriggerFromCfg(
}

export function getDefaultTableToTrack(pg14: boolean): Relations[] {
return [
{
schema_name: 'public',
table_to_track: pg14 ? [{ table_name: '' }] : []
}
];
}
return [
{
schema_name: 'public',
table_to_track: pg14 ? [{ table_name: '' }] : []
}
]
}
Loading