Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need for --begin-sql comments #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Install `python-string-sql` from extensions (`ctrl + shift + x` or `cmd + shift

## Usage

Insert `--sql`, `--beginsql`, or `--begin-sql` at the beginning of the part of the string you would like highlighted and a semicolon, `--endsql`, or `--end-sql` at the end of the highlighted section.
In a `""" multi-line """` or `f""" f-string multiline """` string, use a `select`, `with`, or `-- sql-comment`, and the string will then be treated as embedded SQL.

### Snippets
begin typing `sql` and the autocomplete snippet will appear:
Expand All @@ -25,7 +25,6 @@ begin typing `sql` and the autocomplete snippet will appear:
cmd+s (or ctrl+s on mac) - Insert the following snippet:
```
"""
--sql
SELECT
;
"""
Expand Down
Binary file modified docs/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cur = conn.cursor()

query = """
--begin-sql
SELECT last_name,
start_day,
COUNT(*) AS num_entries
Expand Down
1 change: 0 additions & 1 deletion snippets/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"prefix": "sql",
"body": [
"\"\"\"",
"--sql",
"${1| ,SELECT,WITH|}",
";",
"\"\"\""
Expand Down
18 changes: 8 additions & 10 deletions syntaxes/highlight-sql-string.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
"injectionSelector": "L:string.quoted.multi.python, L:meta.fstring.python - (comment.line.number-sign.python, punctuation.definition.comment.python)",
"patterns": [
{
"begin": "( *--sql| *--beginsql| *--begin-sql)",
Copy link

@cikay cikay Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not recommend to remove the current identifiers. It would break all implementation. Add new ones but do not remove the current ones.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks for getting to this :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are not maintainer haha. You're probably right but ill wait to hear from repo owner/member if they are still alive...

"end": "( *;| *--endsql| *--end-sql)",
"captures": {
"1": {
"name": "variable.parameter"
}
"name": "meta.embedded.sql",
"begin": "\\s*((?i)(select|with)|(--.*))",
"end": "(?=\"\"\")",
"beginCaptures": {
"2": { "name": "keyword.other.DML.sql" },
"3": { "name": "comment.line.double-dash.sql" }
},
"patterns": [
{
"include": "source.sql"
}
{ "include": "source.sql" }
]
}
],
"scopeName": "python-sql.injection"
}
}