imporvement(pg): added wand config for writing sql queries for generic db blocks & supabase postgrest syntax#1197
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR adds AI-powered SQL query generation capabilities ("wand config") to database blocks across MySQL, PostgreSQL, and Supabase integrations. The primary changes include:
Core Functionality: Added wandConfig properties to database block definitions (mysql.ts, postgresql.ts, supabase.ts) that enable AI-assisted query generation. These configs include comprehensive prompts with SQL syntax examples, best practices, and provider-specific instructions to help users generate queries through natural language descriptions.
UI Integration: Enhanced the ShortInput and Code components to support the new wand functionality, adding streaming content generation, hover-triggered wand buttons, and integration with the WandPromptBar component. The implementation includes proper state management for streaming modes and conversation history maintenance.
Security Improvements: Added WHERE clause validation in both MySQL and PostgreSQL utilities to prevent SQL injection attacks by checking for dangerous patterns like union selects, file operations, and comment-based bypasses. Also standardized SSL defaults from 'preferred' to 'required' across all MySQL tools for enhanced security.
Code Standardization: Replaced global crypto.randomUUID() usage with explicit imports from the Node.js crypto module across all database API routes, following modern ES module best practices and improving code clarity.
The wand config system provides specialized generation types (sql-query, postgrest) with provider-specific prompts that guide the AI to generate syntactically correct queries for each database system. This makes database interactions more accessible to non-SQL experts while maintaining proper security practices.
Confidence score: 3/5
- This PR introduces significant new functionality with potential for breaking changes and security implications
- Score reflects concerns about code duplication, breaking API changes, and security validation gaps
- Pay close attention to the UI component changes and database security validation logic
23 files reviewed, 4 comments
...Id]/w/[workflowId]/components/workflow-block/components/sub-block/components/short-input.tsx
Show resolved
Hide resolved
…c db blocks & supabase postgrest syntax (#1197) * add parallel ai, postgres, mysql, slight modifications to dark mode styling * bun install frozen lockfile * new deps * improve security, add wand to short input and update wand config
…c db blocks & supabase postgrest syntax (#1197) * add parallel ai, postgres, mysql, slight modifications to dark mode styling * bun install frozen lockfile * new deps * improve security, add wand to short input and update wand config
…c db blocks & supabase postgrest syntax (simstudioai#1197) * add parallel ai, postgres, mysql, slight modifications to dark mode styling * bun install frozen lockfile * new deps * improve security, add wand to short input and update wand config
Summary
added wand config for writing sql queries for generic db blocks & supabase postgrest syntax
Fixes #240
Type of Change
Testing
Tested manually.
Checklist