frigus02 / vscode-sql-tagged-template-literals

VS Code extension, which enables syntax highlighting for SQL in template literals tagged with an `sql` function
https://marketplace.visualstudio.com/items?itemName=frigus02.vscode-sql-tagged-template-literals
MIT License
34 stars 8 forks source link

Support for postgres.js dynamic inserts #29

Open rolanday opened 11 months ago

rolanday commented 11 months ago

Hello,

Thank you for this great vs-code plug-in! I recently installed and the only issue I've come across so far is it fails to parse sql templates containing dynamic inserts supported by postgres.js:

https://github.com/porsager/postgres#dynamic-inserts

As an example, for the following statement:

// using example provided by postgres docs (above link).
const user = {
  name: 'Murray',
  age: 68
}

await sql`
  insert into users ${
    sql(user, 'name', 'age')
  }
`

Parser complains:

Failed to parse: syntax error at or near "$1".typescript-sql-tagged-template-plugin(100001)

Is dynamic inserts something you can add support for, or is there a way for me to configure vscode-sql-tagged-template-literals to handle?

Thanks!

Edit: I discovered that two plug-ins are installed SQL tagged template literals and `SQL tagged template literals (syntax only), where first depends on "syntax only" plug-in. If I disable the first (keeping just syntax enabled) then the parse error goes away. I'll keep first disable for now since syntax highlighting is the main thing I am after, put will watch this issue because other capabilities are nice to have. Thanks again!

frigus02 commented 11 months ago

Hi. Yeah, in this case I recommend the syntax only plugin.

In theory it would be possible to support this in the plugin that lints the SQL text. But I don't know if I want to support that.

rolanday commented 11 months ago

Thanks for the quick response, and much appreciate the plugin! Super helpful. Thank you :0)