mirror of
https://github.com/simonw/datasette.git
synced 2026-07-09 17:14:35 +02:00
A few more SQLite string fixes, refs #2783
This commit is contained in:
parent
bf3e277c98
commit
54597f22fa
2 changed files with 8 additions and 1 deletions
|
|
@ -1294,9 +1294,11 @@ class StartupError(Exception):
|
|||
_comments_and_strings_re = re.compile(
|
||||
r"""
|
||||
--[^\n]* # single line comment
|
||||
| /\*.*?\*/ # multi line comment
|
||||
| /\*.*?(?:\*/|\Z) # multi line comment, possibly to end-of-input
|
||||
| '(?:''|[^'])*' # single quoted string ('' escapes a quote)
|
||||
| "(?:""|[^"])*" # double quoted identifier ("" escapes a quote)
|
||||
| \[(?:[^\]])*\] # square-bracket quoted identifier
|
||||
| `(?:``|[^`])*` # backtick quoted identifier
|
||||
""",
|
||||
re.DOTALL | re.VERBOSE,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -764,6 +764,11 @@ def test_parse_metadata(content, expected):
|
|||
# Parameters that live inside a comment should be ignored
|
||||
("select :x -- and :ignored", ["x"]),
|
||||
("select :x /* and :ignored */ from t", ["x"]),
|
||||
("select :x /* and :ignored", ["x"]),
|
||||
# Parameters inside quoted identifiers should be ignored
|
||||
("select [a:b] from t where id = :id", ["id"]),
|
||||
("select `a:b` from t where id = :id", ["id"]),
|
||||
("select `a``:b` from t where id = :id", ["id"]),
|
||||
# Parameters inside a string literal should be ignored
|
||||
("select ':ignored' || :real", ["real"]),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue