The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: lowercase the sql templates
Jonathan Summers-Muir6d4092fb3647
diff --git a/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/studio/components/interfaces/Settings/Logs/Logs.constants.tsindex d105adf6496..2bad6329f66 100644--- a/studio/components/interfaces/Settings/Logs/Logs.constants.ts+++ b/studio/components/interfaces/Settings/Logs/Logs.constants.ts@@ -19,12 +19,12 @@ export const TEMPLATES: LogTemplate[] = [mode: 'custom',searchString: `SELECTp.user_name, count(*) as count-FROM postgres_logs- LEFT JOIN UNNEST(metadata) as m ON TRUE- LEFT JOIN UNNEST(m.parsed) AS p ON TRUE-WHERE- REGEXP_CONTAINS(event_message, 'COMMIT')-GROUP BY+from postgres_logs+ left join unnest(metadata) as m on true+ left join unnest(m.parsed) as p on true+where+ regexp_contains(event_message, 'commit')+group byp.user_name`,for: ['database'],@@ -34,11 +34,11 @@ GROUP BYdescription: 'Print all the IP addresses that used Supabase api',mode: 'custom',searchString: `SELECT timestamp, h.x_real_ip-FROM edge_logs- LEFT JOIN UNNEST(metadata) as m ON TRUE- LEFT JOIN UNNEST(m.request) AS r ON TRUE- LEFT JOIN UNNEST(r.headers) AS h ON TRUE-WHERE h.x_real_ip IS NOT NULL+from edge_logs+ left join unnest(metadata) as m on true+ left join unnest(m.request) as r on true+ left join unnest(r.headers) as h on true+where h.x_real_ip is not null`,for: ['api'],},@@ -47,14 +47,14 @@ WHERE h.x_real_ip IS NOT NULLmode: 'custom',searchString: `SELECTcf.country, count(*) as count-FROM edge_logs- LEFT JOIN UNNEST(metadata) as m ON TRUE- LEFT JOIN UNNEST(m.request) AS r ON TRUE- LEFT JOIN UNNEST(r.cf) AS cf ON TRUE-GROUP BY+from edge_logs+ left join unnest(metadata) as m on true+ left join unnest(m.request) as r on true+ left join unnest(r.cf) as cf on true+group bycf.country-ORDER BY- count DESC+order by+ count desc`,for: ['api'],},@@ -65,14 +65,14 @@ ORDER BYtimestamp,event_message,r.origin_time-FROM edge_logs- CROSS JOIN unnest(metadata) as m- CROSS JOIN unnest(m.response) as r-WHERE+from edge_logs+ cross join unnest(metadata) as m+ cross join unnest(m.response) as r+wherer.origin_time > 1000-ORDER BY- timestamp DESC-LIMIT 100+order by+ timestamp desc+limit 100`,for: ['api'],},@@ -83,14 +83,14 @@ LIMIT 100timestamp,event_message,r.status_code-FROM edge_logs+from edge_logscross join unnest(metadata) as mcross join unnest(m.response) as r-WHERE+wherer.status_code >= 500-ORDER BY+order bytimestamp desc-LIMIT 100+limit 100`,for: ['api'],},@@ -101,15 +101,15 @@ LIMIT 100r.path as path,r.search as params,count(timestamp) as c-FROM edge_logs+from edge_logscross join unnest(metadata) as mcross join unnest(m.request) as r-GROUP BY+group bypath,params-ORDER BY+order byc desc-LIMIT 100+limit 100`,for: ['api'],},@@ -119,14 +119,14 @@ LIMIT 100searchString: `SELECTtimestamp,event_message-FROM edge_logs+from edge_logscross join unnest(metadata) as mcross join unnest(m.request) as r-WHERE+wherepath like '%rest/v1%'-ORDER BY+order bytimestamp desc-LIMIT 100+limit 100`,for: ['api'],},@@ -137,37 +137,37 @@ LIMIT 100t.timestamp,p.error_severity,event_message-FROM+frompostgres_logs as tcross join unnest(metadata) as mcross join unnest(m.parsed) as p-WHERE+wherep.error_severity in ('ERROR', 'FATAL', 'PANIC')-ORDER BY+order bytimestamp desc-LIMIT 100+limit 100`,for: ['database'],},{label: 'Error Count by User',mode: 'custom',- searchString: `SELECT+ searchString: `selectcount(t.timestamp) as count,p.user_name,p.error_severity-FROM+frompostgres_logs as tcross join unnest(metadata) as mcross join unnest(m.parsed) as p-WHERE+wherep.error_severity in ('ERROR', 'FATAL', 'PANIC')-GROUP BY+group byp.user_name,p.error_severity-ORDER BY+order bycount desc-LIMIT 100+limit 100`,for: ['database'],},@@ -179,29 +179,25 @@ export const LOG_TYPE_LABEL_MAPPING: { [k: string]: string } = {database: 'Database',}-export const genDefaultQuery = (- table: LogsTableName,- where: string | undefined,- idFilter?: string-) => {+export const genDefaultQuery = (table: LogsTableName, where: string | undefined) => {switch (table) {case 'edge_logs':- return `SELECT id, timestamp, event_message, metadata, request, response, request.method, request.path, response.status_code-FROM ${table}+ return `select id, timestamp, event_message, metadata, request, response, request.method, request.path, response.status_code+from ${table}cross join unnest(metadata) as mcross join unnest(m.request) as requestcross join unnest(m.response) as response${where}-LIMIT 100+limit 100`breakcase 'postgres_logs':- return `SELECT postgres_logs.timestamp, id, event_message, metadata, metadataParsed.error_severity FROM ${table}+ return `select postgres_logs.timestamp, id, event_message, metadata, metadataparsed.error_severity from ${table}cross join unnest(metadata) as m-cross join unnest(m.parsed) as metadataParsed+cross join unnest(m.parsed) as metadataparsed${where}-LIMIT 100+limit 100`break@@ -209,7 +205,7 @@ LIMIT 100return `select id, ${table}.timestamp, event_message, metadata.event_type, metadata.function_id, metadata.level, metadata from ${table}cross join unnest(metadata) as metadata${where}-LIMIT 100+limit 100`break@@ -219,7 +215,7 @@ cross join unnest(metadata) as mcross join unnest(m.response) as responsecross join unnest(m.request) as request${where}-LIMIT 100+limit 100`default:@@ -287,15 +283,13 @@ export const LOGS_TABLES = {fn_edge: LogsTableName.FN_EDGE,}-export const LOGS_SOURCE_DESCRIPTION = {- [LogsTableName.EDGE]: "Logs obtained from the network edge, containing all API requests.",- [LogsTableName.POSTGRES]: "Database logs obtained directly from Postgres." ,- [LogsTableName.FUNCTIONS]: "Function logs generated from runtime execution.",- [LogsTableName.FN_EDGE]: "Function call logs, containing the request and response.",+ [LogsTableName.EDGE]: 'Logs obtained from the network edge, containing all API requests.',+ [LogsTableName.POSTGRES]: 'Database logs obtained directly from Postgres.',+ [LogsTableName.FUNCTIONS]: 'Function logs generated from runtime execution.',+ [LogsTableName.FN_EDGE]: 'Function call logs, containing the request and response.',}-export const genCountQuery = (table: string): string => `SELECT count(*) as count FROM ${table}`export const genQueryParams = (params: { [k: string]: string }) => {