fix: Database studio fixes (#8251)

* disable dynamic fields for db studio config

* Fix SQL safe interpolated arg

* Fix db studio not passing AppEditorContext to modal

* Fix db studio modal grid not being able to move/resize components
This commit is contained in:
Diego Imbert
2026-03-06 17:32:50 +01:00
committed by GitHub
parent 0c89331752
commit 23c2813b62
5 changed files with 75 additions and 22 deletions
+33 -1
View File
@@ -238,7 +238,7 @@ lazy_static::lazy_static! {
// used for `unsafe` sql interpolation
// -- %%name%% (type) = default
static ref RE_ARG_SQL_INTERPOLATION: Regex = Regex::new(r#"(?m)^--\s*%%([a-z_][a-z0-9_]*)%%\s*([\s\w\/]+)?(?: ?\= ?(.+))? *(?:\r|\n|$)"#).unwrap();
static ref RE_ARG_SQL_INTERPOLATION: Regex = Regex::new(r#"(?m)^--\s*%%([a-z_][a-z0-9_]*)%%[ \t]*([\w][\w \t\/]*)?(?: ?\= ?(.+))? *(?:\r|\n|$)"#).unwrap();
}
fn parsed_default(parsed_typ: &Typ, default: String) -> Option<serde_json::Value> {
@@ -1547,4 +1547,36 @@ SELECT $1::integer;
Ok(())
}
#[test]
fn test_parse_pgsql_safe_interpolated_args() -> anyhow::Result<()> {
// There was a bug where enum would be "angrycreative"/"bishop"/"test SELECT x"
let code = r#"
-- %%table_name%% angrycreative/bishop/test
SELECT x
"#;
assert_eq!(
parse_pgsql_sig(code)?,
MainArgSignature {
star_args: false,
star_kwargs: false,
args: vec![Arg {
otyp: Some("__sanitized_enum__".to_string()),
name: "table_name".to_string(),
typ: Typ::Str(Some(vec![
"angrycreative".to_string(),
"bishop".to_string(),
"test".to_string()
])),
default: None,
has_default: false,
oidx: None,
},],
no_main_func: None,
has_preprocessor: None
}
);
Ok(())
}
}
@@ -4,7 +4,12 @@
import { type GridApi, createGrid, type IDatasource } from 'ag-grid-community'
import { sendUserToast } from '$lib/utils'
import { createEventDispatcher, getContext, mount, unmount, untrack } from 'svelte'
import type { AppViewerContext, ComponentCustomCSS, ContextPanelContext } from '../../../types'
import {
type AppEditorContext,
type AppViewerContext,
type ComponentCustomCSS,
type ContextPanelContext
} from '../../../types'
import type { TableAction, components } from '$lib/components/apps/editor/component'
import { deepEqual } from 'fast-equals'
@@ -62,9 +67,15 @@
const context = getContext<AppViewerContext>('AppViewerContext')
const contextPanel = getContext<ContextPanelContext>('ContextPanel')
const editorContext = getContext<AppEditorContext>('AppEditorContext')
const { app, selectedComponent, componentControl, darkMode, mode } = context
let css = $state(initCss($app.css?.aggridcomponent, untrack(() => customCss)))
let css = $state(
initCss(
$app.css?.aggridcomponent,
untrack(() => customCss)
)
)
let selectedRowIndex = -1
@@ -151,7 +162,8 @@
const componentContext = new Map<string, any>([
['AppViewerContext', context],
['ContextPanel', contextPanel]
['ContextPanel', contextPanel],
['AppEditorContext', editorContext]
])
const taComponent = withProps(AppAggridTableActions, {
@@ -280,10 +280,7 @@
}
} catch {}
} else {
const drawerAlreadyHandledFocusedGrid =
item?.data.type === 'drawercomponent' &&
$focusedGrid?.parentComponentId === befSelected
if (!drawerAlreadyHandledFocusedGrid) {
if ($focusedGrid?.parentComponentId !== befSelected) {
$focusedGrid = undefined
}
}
@@ -4159,14 +4159,16 @@ This is a paragraph.
type: 'static',
fieldType: 'resource',
subFieldType: 'mysql',
value: ''
value: '',
allowTypeChange: false
} as StaticAppInput,
table: {
fieldType: 'select',
subFieldType: 'db-table',
type: 'static',
selectOptions: [],
value: undefined
value: undefined,
allowTypeChange: false
}
},
ms_sql_server: {
@@ -4174,14 +4176,16 @@ This is a paragraph.
type: 'static',
fieldType: 'resource',
subFieldType: 'ms_sql_server',
value: ''
value: '',
allowTypeChange: false
} as StaticAppInput,
table: {
fieldType: 'select',
subFieldType: 'db-table',
type: 'static',
selectOptions: [],
value: undefined
value: undefined,
allowTypeChange: false
}
},
snowflake: {
@@ -4189,14 +4193,16 @@ This is a paragraph.
type: 'static',
fieldType: 'resource',
subFieldType: 'snowflake',
value: ''
value: '',
allowTypeChange: false
} as StaticAppInput,
table: {
fieldType: 'select',
subFieldType: 'db-table',
type: 'static',
selectOptions: [],
value: undefined
value: undefined,
allowTypeChange: false
}
},
bigquery: {
@@ -4204,14 +4210,16 @@ This is a paragraph.
type: 'static',
fieldType: 'resource',
subFieldType: 'bigquery',
value: ''
value: '',
allowTypeChange: false
} as StaticAppInput,
table: {
fieldType: 'select',
subFieldType: 'db-table',
type: 'static',
selectOptions: [],
value: undefined
value: undefined,
allowTypeChange: false
}
},
ducklake: {
@@ -4219,14 +4227,16 @@ This is a paragraph.
type: 'static',
fieldType: 'ducklake',
subFieldType: 'ducklake',
value: ''
value: '',
allowTypeChange: false
} as StaticAppInput,
table: {
fieldType: 'select',
subFieldType: 'db-table',
type: 'static',
selectOptions: [],
value: undefined
value: undefined,
allowTypeChange: false
}
},
datatable: {
@@ -4234,14 +4244,16 @@ This is a paragraph.
type: 'static',
fieldType: 'datatable',
subFieldType: 'datatable',
value: ''
value: '',
allowTypeChange: false
} as StaticAppInput,
table: {
fieldType: 'select',
subFieldType: 'db-table',
type: 'static',
selectOptions: [],
value: undefined
value: undefined,
allowTypeChange: false
}
}
}
@@ -221,7 +221,7 @@
const pointerdown = ({ clientX, clientY }) => {
dragClosure = () => {
dragClosure = undefined
ctx.componentActive.set(true)
ctx?.componentActive.set(true)
initX = (clientX / $scale) * 100
initY = (clientY / $scale) * 100
@@ -401,7 +401,7 @@
}, 50)
const pointerup = (e) => {
ctx.componentActive.set(false)
ctx?.componentActive.set(false)
stopAutoscroll()
window.removeEventListener('pointerdown', pointerdown)