Commit Graph
3 Commits
Author SHA1 Message Date
nngoandClaude Sonnet 4.6 f680bfe3a3 Add schema-aware SQL auto-complete to the SQL editor
New file app/ui/sql_completer.py:
- SqlCompleter (QObject) owns a _CompletionPopup (QListWidget) that
  floats above the editor as a ToolTip-style frameless window styled
  to match the Catppuccin Mocha theme.
- SQL keyword pool sourced directly from syntax_highlighter._KEYWORDS,
  _TYPES, _FUNCTIONS so the two features stay in sync.
- Schema data (tables, views, columns) loaded asynchronously via
  SchemaWorker; a generation counter discards stale results when the
  database changes rapidly.
- Column loading is lazy: fires only when the user types "table."
  (dot-qualified prefix), avoiding upfront cost for wide schemas.
- _extract_prefix() uses a regex to detect both bare words and
  "table.col" dot notation; guards against completing inside string
  literals by counting unescaped quotes to the left of the cursor.
- _accept_completion() replaces only the typed prefix, preserving any
  qualifier already in the document (e.g. "orders.cu" → "orders.customer_id").

Changes to app/ui/sql_editor.py:
- CodeEditor.set_completer() attaches the completer and stores it.
- keyPressEvent priority order:
    1. Popup visible → Esc hides, Enter/Tab accepts, Up/Down navigates.
    2. Ctrl+Space → force-show completions (1-char minimum).
    3. Tab (no popup) → existing 4-space insert behaviour preserved.
    4. Ctrl+/ → existing comment-toggle preserved.
    5. All other keys → super() then auto-trigger (2-char minimum).
- focusOutEvent hides the popup when the editor loses focus.
- EditorTab._build_ui() creates SqlCompleter, attaches it, and calls
  set_context() if a driver is already present.
- EditorTab.set_context() updates driver/database and reloads schema.
- _maybe_invalidate_schema() re-fetches schema after CREATE/DROP/ALTER
  so newly created tables appear in completions immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 16:28:58 -04:00
nngoandClaude Sonnet 4.6 4ccc81955e Fix high-severity issues: implement SSL and warn on raw-SQL filter
SSL was wired through the UI and ConnectionProfile but never actually
applied in any driver or passed from the connection builder.

- main_window: pass ssl/ssl_ca/ssl_cert/ssl_key from profile into
  the driver config dict so drivers can act on them
- MySQL: add ssl={ca,cert,key} to pymysql connect kwargs when enabled
- PostgreSQL: set sslmode=verify-ca (with CA) or require, plus
  sslrootcert/sslcert/sslkey when provided
- MSSQL: switch Encrypt=yes + TrustServerCertificate=no when SSL is
  on; Encrypt=no + TrustServerCertificate=yes otherwise
- SQLite: no change needed (local file, no network layer)

WHERE filter: add tooltip explicitly labelling the input as raw SQL
so users understand arbitrary expressions are executed directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 16:07:02 -04:00
nngo b01ad5ea40 Initial Codes 2026-05-21 15:46:41 -04:00