Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 14, 2025

Fixes #2562

This PR implements a new multi-line text field in the Query Settings Dialog where users can input initialization pragmas that will be automatically prepended to their SQL queries during execution.

🎯 Changes Made

UI Components

  • Added a new "Pragmas" multi-line TextArea field to the Query Settings Dialog
  • Positioned between "Limit rows" and "Timeout" fields as shown in the design reference
  • Field defaults to PRAGMA OrderedColumns; as specified
  • Includes proper validation and error handling

Backend Integration

  • Query Execution: Modified both streaming and regular query execution to prepend pragmas to query text
  • State Management: Integrated with existing Redux query settings state
  • Persistence: Pragmas setting persists across sessions like other query settings
  • Validation: Added Zod schema validation for the pragmas field

Localization

  • Added English translation: "form.pragmas": "Pragmas"
  • Added Russian translation: "form.pragmas": "Прагмы"

Technical Implementation

// Example of pragma prepending logic
const finalQuery = prepareQueryWithPragmas(userQuery, settings.pragmas);
// Result: "PRAGMA OrderedColumns;\n\nSELECT * FROM table;"

🧪 Testing

  • ✅ Updated existing tests to include pragmas field
  • ✅ Added comprehensive integration tests for pragma functionality
  • ✅ All build and test pipelines passing
  • ✅ Verified pragma preparation handles edge cases (empty pragmas, missing semicolons, multiple pragmas)

📸 Screenshot

The Query Settings Dialog now includes the new Pragmas field:

Query Settings Dialog with Pragmas Field

🚀 Usage

  1. Open Query Settings Dialog (⚙️ button in query editor)
  2. Edit pragmas in the multi-line text area (defaults to "PRAGMA OrderedColumns;")
  3. Save settings
  4. When executing queries, pragmas are automatically prepended to the query text

Example:

  • User sets pragmas: PRAGMA OrderedColumns;\nPRAGMA AnsiOptionalAS;
  • User query: SELECT * FROM users;
  • Executed query:
PRAGMA OrderedColumns;
PRAGMA AnsiOptionalAS;

SELECT * FROM users;

🔧 Technical Details

  • Type Safety: Full TypeScript support with proper type definitions
  • Validation: Zod schema ensures data integrity
  • Backward Compatibility: Existing query settings continue to work unchanged
  • Performance: Minimal overhead with efficient string concatenation
  • Error Handling: Graceful handling of empty or malformed pragmas

The implementation follows the existing patterns in the codebase and maintains consistency with other query settings fields.

This pull request was created as a result of the following prompt from Copilot chat.

Implement a new multi-line text field in the Query Settings Dialog where users can input initialization pragmas (e.g., "PRAGMA OrderedColumns;").

Requirements:

  1. Add a multi-line text box labeled (e.g., "Pragmas") to the Query Settings Dialog.
  2. Store its value in the query execution settings.
  3. When a SQL query is executed, prepend the content of this field to the beginning of the query.
  4. Default the field to "PRAGMA OrderedColumns;".
  5. Update validation, localization, and Redux state as needed so this setting persists and works like other query settings.
  6. Update tests (unit and integration) to cover the new field and its usage.
  7. Update i18n files to add new strings if necessary.

Reference: #2562

Design inspiration: Image


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
354 348 0 4 2
Test Changes Summary ⏭️2

⏭️ Skipped Tests (2)

  1. Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view (tenant/diagnostics/tabs/queries.test.ts)
  2. Copy result button copies to clipboard (tenant/queryEditor/queryEditor.test.ts)

Bundle Size: 🔺

Current: 85.16 MB | Main: 85.12 MB
Diff: +0.04 MB (0.05%)

⚠️ Bundle size increased. Please review.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Copilot AI changed the title [WIP] Add field for pragmas in Query Settings Dialog Add multi-line Pragmas field to Query Settings Dialog Jul 14, 2025
Copilot AI requested a review from adameat July 14, 2025 06:53
Copilot finished work on behalf of adameat July 14, 2025 06:53
@Raubzeug Raubzeug changed the title Add multi-line Pragmas field to Query Settings Dialog feat(query): add multi-line Pragmas field to Query Settings Dialog Jul 14, 2025
@Raubzeug Raubzeug marked this pull request as ready for review July 15, 2025 07:36
@Raubzeug Raubzeug added this pull request to the merge queue Jul 15, 2025
Merged via the queue into main with commit 2010164 Jul 15, 2025
7 checks passed
@Raubzeug Raubzeug deleted the copilot/fix-ba8fb5ed-bf49-4389-8579-de592359dc57 branch July 15, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add field for pragmas in query settings dialog

3 participants