Skip to content

Latest commit

 

History

History

extension-syntax-only

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

VS Code extension: SQL tagged template literals (syntax only)

A VS Code extension, which enables SQL syntax highlighting for template literals tagged with an sql or sqlFragment function in JavaScript and TypeScript files.

Image of code snippet showing SQL syntax highlighting

Supported are:

  • Tagged template literals:

    sql`SELECT * FROM user`;
    sqlFragment`WHERE id = ${id}`;
  • Functions returning a template tag:

    sql("get-user")`SELECT * FROM user`;
    sqlFragment("filter-by-id")`WHERE id = ${id}`;
  • Comments before template literals:

    /* sql * / `SELECT * FROM user`
    /* sqlFragment */ `WHERE id = ${id}`;
  • And most combinations with most TypeScript features. Some examples:

    sql<With, Generic<Types>>`SELECT * FROM user`;
    nested?.optional?.sql`SELECT * FROM user`;
    sql("with", Infinity, `params`)`SELECT * FROM user`;

If you're using PostgreSQL, have a look at SQL tagged template literals, which is the same extension but also supports SQL syntax validation, type checking and formatting.

Thanks

This is based on several great existing extensions: