mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 16:00:38 +00:00
fix: capture index schema at open time, gate ops on feature, surface raw-SQL hints
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
}
|
||||
let { dbIndexOps, tableKey, schema, availableColumns }: Props = $props()
|
||||
|
||||
// Keep in sync with PG_INDEX_METHODS in backend/windmill-common/src/query_builders.rs
|
||||
const INDEX_METHODS = ['btree', 'hash', 'gin', 'gist', 'brin', 'spgist']
|
||||
|
||||
let indexes = resource(
|
||||
@@ -140,11 +141,12 @@
|
||||
confirm.loading = true
|
||||
try {
|
||||
await confirm.onConfirm()
|
||||
confirm = undefined
|
||||
} catch (e) {
|
||||
toastErr(e)
|
||||
if (confirm) confirm.loading = false
|
||||
confirm.loading = false
|
||||
return
|
||||
}
|
||||
confirm = undefined
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -264,7 +266,11 @@
|
||||
<Toggle
|
||||
size="xs"
|
||||
bind:checked={column.isExpression}
|
||||
options={{ right: 'expr', rightTooltip: 'Use a raw SQL expression' }}
|
||||
options={{
|
||||
right: 'expr',
|
||||
rightTooltip:
|
||||
'Treat the value as a raw SQL expression (e.g. lower(email)) — inserted verbatim, not escaped'
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
color="light"
|
||||
@@ -318,7 +324,10 @@
|
||||
/>
|
||||
{#if showAdvanced}
|
||||
<div class="flex flex-col gap-3 border-l-2 border-surface-selected pl-3">
|
||||
<Label label="Partial index predicate (WHERE)">
|
||||
<Label
|
||||
label="Partial index predicate (WHERE)"
|
||||
tooltip="Raw SQL inserted verbatim after WHERE — not escaped"
|
||||
>
|
||||
<TextInput
|
||||
bind:value={form.where}
|
||||
inputProps={{ type: 'text', placeholder: 'active = true' }}
|
||||
|
||||
@@ -236,7 +236,9 @@
|
||||
}
|
||||
)
|
||||
|
||||
let dbIndexManagerState: { open: boolean; tableKey?: string } = $state({ open: false })
|
||||
let dbIndexManagerState: { open: boolean; tableKey?: string; schemaKey?: string } = $state({
|
||||
open: false
|
||||
})
|
||||
|
||||
let newSchemaDialogOpen = $state(false)
|
||||
let newSchemaName = $state('')
|
||||
@@ -526,7 +528,11 @@
|
||||
displayName: 'Manage indexes',
|
||||
icon: ListTree,
|
||||
action: () => {
|
||||
dbIndexManagerState = { open: true, tableKey }
|
||||
dbIndexManagerState = {
|
||||
open: true,
|
||||
tableKey,
|
||||
schemaKey: selected.schemaKey
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -684,12 +690,13 @@
|
||||
>
|
||||
{#if dbIndexManagerState.tableKey && dbIndexOps}
|
||||
{@const indexTableKey = dbIndexManagerState.tableKey}
|
||||
{@const indexSchemaKey = dbIndexManagerState.schemaKey}
|
||||
<DBIndexManager
|
||||
{dbIndexOps}
|
||||
tableKey={indexTableKey}
|
||||
schema={selected.schemaKey}
|
||||
schema={indexSchemaKey}
|
||||
availableColumns={Object.keys(
|
||||
dbSchema?.schema?.[selected.schemaKey ?? '']?.[indexTableKey] ?? {}
|
||||
dbSchema?.schema?.[indexSchemaKey ?? '']?.[indexTableKey] ?? {}
|
||||
)}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
@@ -166,10 +166,9 @@
|
||||
input: _input,
|
||||
workspace: $workspaceStore
|
||||
})}
|
||||
dbIndexOps={dbIndexOpsWithPreviewScripts({
|
||||
input: _input,
|
||||
workspace: $workspaceStore
|
||||
})}
|
||||
dbIndexOps={getDbFeatures(_input).indexes
|
||||
? dbIndexOpsWithPreviewScripts({ input: _input, workspace: $workspaceStore })
|
||||
: undefined}
|
||||
initialTableKey={input.specificTable}
|
||||
initialSchemaKey={input.type == 'database' ? input.specificSchema : undefined}
|
||||
asset={_input.type == 'ducklake'
|
||||
|
||||
Reference in New Issue
Block a user