SQL
Native SQL diagnostics and typed Kotlin, Python and Rust generation for
SQLDelight-style SQLite .sq files. No Java, Gradle, Python, Cargo or database server
is required to use the extension. The compiler is bundled and works offline.
Use
Open a .sq file containing a schema and labelled queries. The .sq files of one folder
are one database: a file may use tables and views declared in its siblings.
CREATE TABLE Dog (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
born INTEGER NOT NULL
);
insert:
INSERT INTO Dog (name, born) VALUES (?, ?) RETURNING *;
selectNames:
SELECT name FROM Dog WHERE born < :year ORDER BY name;
Errors appear in Problems as you type, including unsaved changes. The editor offers
schema-aware completion, column/type hover, definitions and a document outline.
Choose SQL: Generate Kotlin, SQL: Generate Python or SQL: Generate Rust in
the Command Palette or editor context menu. Generated code opens in a separate unsaved
editor; save it wherever your build needs it. Existing files are never overwritten.
Generated Kotlin uses SQLDelight 2.4.0 runtime/driver APIs. Python uses standard-library
sqlite3; Rust uses rusqlite. The latter two return checked typed rows and leave
transactions to your application. Kotlin package and database names are configurable
with sql.packageName and sql.databaseName. Columns declared with a SQLDelight adapter
(kind TEXT AS pkg.Kind) need a target type for Python and Rust: set sql.pythonAdapters
(e.g. {"pkg.Kind": "kinds.Kind"}) and sql.rustAdapters (e.g. {"pkg.Kind": "Kind"});
an unmapped type is reported as a generation error.
Supported SQL
This first release supports a bounded SQLite subset: CREATE TABLE with INTEGER, REAL,
TEXT and BLOB, NOT NULL, INTEGER PRIMARY KEY/AUTOINCREMENT; labelled SELECT and
single-row INSERT with binds, including RETURNING. SELECT supports projection/table
aliases, qualified columns/wildcards, AND-connected column/bind comparisons and ORDER BY.
Named :name, anonymous ? and repeated binds are supported. Nullability is preserved.
Schemas are shared by the .sq files of one folder, not across folders. Expressions, aggregates,
CTEs, migrations, custom adapters and collection binds are not implemented. Unsupported
SQL produces an explicit diagnostic. Kotlin generation also rejects nullable WHERE binds
until SQLDelight null-comparison parity is established. This is not a general SQL client:
it does not connect to or execute queries against your databases.
Install the Marketplace build matching your platform. The bundled native compiler runs
locally. The extension sends no SQL, source code or telemetry over the network, and does
not download executables. sql.compilerPath optionally selects another compatible
absolute executable path in a trusted workspace; otherwise the bundled compiler runs.
Problems and support: support@optersoft.com.