Skip to content

sql

This directory provides support for SQL within the Talon voice coding ecosystem. It defines the syntax rules, operator overrides, standard keywords, and common functions required to write SQL queries efficiently using voice commands.

The files in this directory work together to configure the SQL language context:

  • sql.py establishes the programming language context (code.language: sql) and overrides global programming behaviors to match SQL-specific syntax. It maps standard mathematical and logical operators—such as defining MATH_NOT_EQUAL as <> and setting up logical AND/OR operators. It also implements actions for handling null checks (IS NULL, IS NOT NULL) and formats generic database function calls.
  • sql.talon defines the voice command interface for SQL. It activates when editing a SQL file and enables spoken commands for database-centric operations. These include basic queries ("select", "select star from", "where", "group by"), joins ("inner join", "left outer join"), and structural formatting (like the "column" command to insert a comma and start a new line).
  • code_common_function.talon-list populates the standard voice list for database-specific functions. It maps spoken names to SQL aggregate functions such as Count, Min, and Max, ensuring they conform to standard SQL dialect casing.

How They Work Together

When you open a SQL file, Talon detects the code.language: sql context.

  1. Operators & Actions: sql.py registers standard SQL operator mappings. When generic programming commands (e.g., "op equal" or "op not equal") are spoken, they resolve to = and <> respectively instead of standard programming defaults like == and !=.
  2. Voice Commands: sql.talon consumes these context-aware actions. When a user says "inner join", it leverages the generic user.insert_between action to output INNER JOIN ON and places the cursor right in the middle for seamless entry.
  3. Common Functions: Spoken functions defined in code_common_function.talon-list are formatted dynamically using the code_insert_function helper in sql.py, utilizing snippets for consistent call structuring.