The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
bugfix for where query building
TzeYiing46cbdd4d41de
diff --git a/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/studio/components/interfaces/Settings/Logs/Logs.constants.tsindex 6688df8b457..10c32294b9a 100644--- a/studio/components/interfaces/Settings/Logs/Logs.constants.ts+++ b/studio/components/interfaces/Settings/Logs/Logs.constants.ts@@ -70,10 +70,10 @@ export const LOG_TYPE_LABEL_MAPPING: { [k: string]: string } = {database: 'Database',}-export const genDefaultQuery = (table: string): string => `SELECT+export const genDefaultQuery = (table: string, where: string = ''): string => `SELECTid, timestamp, event_message, metadataFROM- ${table}+ ${table}${where ? '\nWHERE ' + where : ''}`-export const genCountQuery = (table: string): string => `SELECT count(*) as count FROM ${table}`+export const genCountQuery = (table: string, where: string=""): string => `SELECT count(*) as count FROM ${table}${where ? '\nWHERE ' + where : ''}`diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsxindex 38fd831a88c..1cdca62082f 100644--- a/studio/pages/project/[ref]/settings/logs/[type].tsx+++ b/studio/pages/project/[ref]/settings/logs/[type].tsx@@ -71,7 +71,7 @@ export const LogPage: NextPage = () => {const checkIfSelectQuery = (value: string) =>value.toLowerCase().includes('select') ? true : falseconst isSelectQuery = checkIfSelectQuery(editorValue)-+ const table = type === 'api' ? 'edge_logs' : 'postgres_logs'useEffect(() => {setParams({ ...params, type: type as string })}, [type])@@ -148,7 +148,7 @@ export const LogPage: NextPage = () => {const countUrl = `${API_URL}/projects/${ref}/analytics/endpoints/logs.${type}?${genQueryParams({...params,- sql: genCountQuery(type === 'api' ? 'edge_logs' : 'postgres_logs'),+ sql: genCountQuery(table),period_start: String(latestRefresh),})}`const { data: countData } = useSWR<Count>(countUrl, get, { refreshInterval: 5000 })@@ -172,7 +172,7 @@ export const LogPage: NextPage = () => {setMode('custom')onSelectTemplate({mode: 'custom',- searchString: genDefaultQuery(type === 'api' ? 'edge_logs' : 'postgres_logs'),+ searchString: genDefaultQuery(table),})} else {setMode('simple')@@ -202,7 +202,7 @@ export const LogPage: NextPage = () => {const handleEditorSubmit = () => {setParams((prev) => ({...prev,- sql: editorValue,+ sql: checkIfSelectQuery(editorValue) ? editorValue : genDefaultQuery(table, editorValue),search_query: '',}))router.push({