mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
501666e504
## Context We previously introduced a behaviour for the explorer home tab's chat form to run a SQL Query if the input is detected to be a SQL query. Adjusting it to shift that behaviour into a secondary action instead <img width="740" height="210" alt="image" src="https://github.com/user-attachments/assets/d4b1fec1-f38c-426f-8108-b50ead1a61ca" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * SQL statements entered in Explorer can be run directly with a dedicated “Run SQL” action. * Assistant forms support context-specific submit icons, labels, tooltips, and accessibility text. * **Bug Fixes** * Improved SQL detection for multi-statement queries. * Prevented mixed SQL and conversational text from being treated as executable SQL. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { isSqlStatement } from './ExplorerHomeTab.utils'
|
|
|
|
describe('isSqlStatement', () => {
|
|
it.each([
|
|
'select * from profiles',
|
|
'SELECT id FROM profiles WHERE id = 1;',
|
|
"insert into logs (msg) values ('hi')",
|
|
'update profiles set name = null',
|
|
'delete from profiles where id = 1',
|
|
'with recent as (select 1) select * from recent',
|
|
' \n select 1',
|
|
'-- get everyone\nselect * from profiles',
|
|
'create table users (id serial primary key)',
|
|
'CREATE OR REPLACE FUNCTION foo() RETURNS void AS $$ BEGIN END; $$ LANGUAGE plpgsql',
|
|
'create policy my_policy on profiles for select using (true)',
|
|
'show search_path',
|
|
'SHOW ALL;',
|
|
'set search_path to public',
|
|
"SET TIME ZONE 'UTC'",
|
|
'select * from a;\n\nselect * from b;',
|
|
])('returns true for %s', (message) => {
|
|
expect(isSqlStatement(message)).toBe(true)
|
|
})
|
|
|
|
it.each([
|
|
'',
|
|
' ',
|
|
'How do I add a new column to my table?',
|
|
'What indexes exist on my users table?',
|
|
'Explain how RLS works',
|
|
'Can you help me select the right plan for my project?',
|
|
'Create a new table for storing user profiles',
|
|
'Show me my tables',
|
|
'Set up RLS on my users table',
|
|
'With my current schema, what tables should I add?',
|
|
'select * from colors;\n\nhelp me figure out what is wrong with this',
|
|
])('returns false for %s', (message) => {
|
|
expect(isSqlStatement(message)).toBe(false)
|
|
})
|
|
})
|