Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

added editor value cleaning

TzeYiing8e7e8d4cce19
diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsx
index ac04177c511..d7789681da8 100644
--- a/studio/pages/project/[ref]/settings/logs/[type].tsx
+++ b/studio/pages/project/[ref]/settings/logs/[type].tsx
@@ -180,8 +180,8 @@ export const LogPage: NextPage = () => {
setEditorValue(template.searchString)
setParams((prev) => ({
...prev,
- where: isSelectQuery ? '' : template.searchString,
- sql: isSelectQuery ? template.searchString : '',
+ where: isSelectQuery ? '' : cleanEditorValue(template.searchString),
+ sql: isSelectQuery ? cleanEditorValue(template.searchString) : '',
search_query: '',
timestamp_end: '',
}))
@@ -191,8 +191,8 @@ export const LogPage: NextPage = () => {
const handleEditorSubmit = () => {
setParams((prev) => ({
...prev,
- where: isSelectQuery ? '' : editorValue,
- sql: isSelectQuery ? editorValue : '',
+ where: isSelectQuery ? '' : cleanEditorValue(editorValue),
+ sql: isSelectQuery ? cleanEditorValue(editorValue) : '',
search_query: '',
}))
if (!logsQueryParamsSyncing) return
@@ -200,7 +200,7 @@ export const LogPage: NextPage = () => {
pathname: router.pathname,
query: {
...router.query,
- q: editorValue,
+ q: cleanEditorValue(editorValue),
s: undefined,
te: undefined,
},
@@ -227,7 +227,10 @@ export const LogPage: NextPage = () => {
})
setEditorValue('')
}
-
+ const cleanEditorValue = (value: string) => {
+ if (typeof value !== "string") return value
+ return value.replace(/\n/g, ' ')
+ }
return (
<SettingsLayout title={title}>
<div className="h-full flex flex-col flex-grow">
diff --git a/studio/tests/pages/projects/logs.test.js b/studio/tests/pages/projects/logs.test.js
index c2799b42acd..da0a33eb36d 100644
--- a/studio/tests/pages/projects/logs.test.js
+++ b/studio/tests/pages/projects/logs.test.js
@@ -297,7 +297,7 @@ test('custom sql querying', async () => {
expect(editor).toBeTruthy()
})
editor = container.querySelector('.monaco-editor')
- userEvent.type(editor, 'select count(*) as my_count from edge_logs')
+ userEvent.type(editor, 'select \ncount(*) as my_count \nfrom edge_logs')
// should show sandbox warning alert
await waitFor(() => screen.getByText(/restricted to a 7 day querying window/))
@@ -305,6 +305,7 @@ test('custom sql querying', async () => {
userEvent.click(screen.getByText('Run'))
await waitFor(
() => {
+ expect(get).not.toHaveBeenCalledWith(expect.stringContaining(encodeURI('\n')))
expect(get).toHaveBeenCalledWith(expect.stringContaining('sql='))
expect(get).toHaveBeenCalledWith(expect.stringContaining('select'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('edge_logs'))