Generates types for your SQL.
select-types-faster.mov
Beta status. My main focuses are:
And this project when there's time.
Documented issues: https://github.com/vlcn-io/typed-sql/issues
https://www.youtube.com/watch?v=avGari4souM&feature=youtu.be
Types are generated via a watch task installed with @vlcn.io/typed-sql-cli
.
pnpm install @vlcn.io/typed-sql-cli`
See the cli package
After installing the cli, see the runtime component package.
It is possible to do type generation for template strings which are combinations of template strings. E.g.,
const query = sql`SELECT * FROM ${table} WHERE ${where_clauses}`;
Assuming that some type information is available on the parameters to the template tag. E.g., typeof table = 'foo' | 'bar' | 'baz'
This is not yet supported.
See issue 10
SQLite lets users declare custom types in their create table statements.
CREATE TABLE foo (
id TEXT PRIMARY KEY,
b MyCustomType,
c MyOtherCustomType
);
We could parse these out and map them to actual typescript types. Doing this would require some runtime layer to convert columns to the correct types.
Python bindings have done this -- https://docs.python.org/3/library/sqlite3.html#sqlite3-converters
See issue 8
SQLite doesn't return bools! True is 1
and False is 0
. Given this library currently does not handle execution, and only type generation, bools
are typed as number
I've not implemented a language server yet so intellisense, within the sql
and schema
template tags, currently does not exist. It is planned.
Highlighting inside the sql
and schema
template tags is not yet supported.