barklan / inline_sql_syntax

Highlight and lint inline SQL strings.
https://marketplace.visualstudio.com/items?itemName=qufiwefefwoyn.inline-sql-syntax
MIT License
57 stars 24 forks source link

Support for strings starting with "-- sql" #39

Closed radoslawch closed 2 years ago

radoslawch commented 2 years ago

Assuming Ruby (on Rails, with ActiveRecord) and MySQL/MariaDB - these databases require a space after "--" in a comment.

Example

# valid MySQL/MariaDB query
queryA = Model.where("value=1").select("
-- sql
valueA AS A,
valueB AS B
")

# not valid MySQL/MariaDB query :(
queryB = Model.where("value=1").select("
--sql
valueA AS A,
valueB AS B
")

Current behaviour

In queryA: SQL is not highlighted.

In queryB: SQL is highlighted but it's not valid MySQL/MariaDB query.

Expected behaviour

Both queries should have highlighted SQL.

Delicious-Bacon commented 2 years ago

I also have issues due to this.

Here's the official MariaDB docs on commenting: MariaDB comment syntax

Could we have some VSCode settings or more defaults to fix this? Such as this:

"inlineSQL.lintSQLCommentLine": [
"`--sql",
"`-- sql",
"\"--sql",
"\"\"\"--sql",
],

Right now we have:

Linting and diagnostics powered entirely by awesome joereynolds/sql-lint and works for multiline strings that start with either `--sql (backtick followed by --sql), "--sql or """--sql.

Obviously, we lack the `-- sql.

barklan commented 2 years ago

Fixed in v2.13.0. Syntax highlighting and diagnostics should work for queries starting with --\s*sql regex.