Files
coder/coderd/database/sqlxqueries
Steven Masley 8b125d6c5d chore: Implement joins with golang templates (#6429)
* feat: Implement view for workspace builds to include rbac info

* Removes the need to fetch the workspace to run an rbac check.
* chore: Use workspace build as RBAC object
* chore: Use golang templates instead of sqlc files
2023-03-10 09:44:38 -06:00
..

Editor/IDE config

To edit template files, it is best to configure your IDE to work with go template files. VSCode gives better highlighting support, as the Goland highlighting tends to recognize the sql as invalid and shows many sql errors in the template file.

VSCode

Required extension (Default Golang Extension): https://marketplace.visualstudio.com/items?itemName=golang.Go

The default extension supports syntax highlighting, but requires a configuration change. You must add this section to your golang extension settings:

    "gopls": {
        "ui.semanticTokens": true
    },

The VSCode extension does not support both go template and postgres highlighting. I suggest you use Postgres highlighting, as it is much easier to work with. You can switch between the two with:

  1. ctl + shift + p
  2. "Change language Mode"
  3. "Postgres" or "Go Template File"
  • Feel free to create a permanent file association with *.gosql files.

Goland

Goland supports template highlighting out of the box. To associate sql files, add a new file type in Editor settings. Select "Go template files". Add a new filename of *.gosql and select "postgres" as the "Template Data Language".

Goland language configuration

It also helps to support the sqlc type variables. You can do this by adding "User Parameters" in database queries.

Goland language configuration

You can also add dump.sql as a DDL data source for proper table column recognition.