The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: Parse unqualified SQL functions as SQL snippet in the Cron jobs UI (#41593)
Ivan Vasilove561196f0756
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.ts b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.tsindex dfe96116478..158a9c18c1b 100644--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.ts+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.test.ts@@ -41,6 +41,16 @@ describe('parseCronJobCommand', () => {})})+ it('should return a sql function command when the function name contains an underscore', () => {+ const command = 'SELECT random_schema.function_1()'+ expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({+ type: 'sql_function',+ schema: 'random_schema',+ functionName: 'function_1',+ snippet: command,+ })+ })+it('should return a sql snippet command when the command is SELECT public.test_fn(1, 2)', () => {const command = 'SELECT public.test_fn(1, 2)'expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({@@ -49,6 +59,30 @@ describe('parseCronJobCommand', () => {})})+ it('should return a sql snippet command when the command is using a SQL function from the search path', () => {+ const command = 'SELECT test_cron_function()'+ expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({+ type: 'sql_snippet',+ snippet: command,+ })+ })++ it('should return a sql snippet command when the command is SELECT .()', () => {+ const command = 'SELECT .()'+ expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({+ type: 'sql_snippet',+ snippet: command,+ })+ })++ it('should return a sql snippet command when the command is SELECT schema.()', () => {+ const command = 'SELECT schema.()'+ expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({+ type: 'sql_snippet',+ snippet: command,+ })+ })+it('should return a edge function config when the command posts to its own supabase.co project', () => {const command = `select net.http_post( url:='https://random_project_ref.supabase.co/functions/v1/_', headers:=jsonb_build_object('Authorization', 'Bearer something'), body:='', timeout_milliseconds:=5000 );`expect(parseCronJobCommand(command, 'random_project_ref')).toStrictEqual({diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsxindex 2f726f8050a..75ef9acf94e 100644--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsx+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobs.utils.tsx@@ -127,7 +127,7 @@ export const parseCronJobCommand = (originalCommand: string, projectRef: string)}}- const regexDBFunction = /select\s+[a-zA-Z-_]*\.?[a-zA-Z-_]*\s*\(\)/g+ const regexDBFunction = /select\s+[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+\s*\(\)/gif (command.toLocaleLowerCase().match(regexDBFunction)) {const [schemaName, functionName] = command.replace('SELECT ', '')