mirror of
https://github.com/hanzo-ds/connect.git
synced 2026-10-30 20:31:24 +00:00
* fix unescaped inner quotes in pre-quoted identifiers * update misleading comment
44 lines
1016 B
Python
44 lines
1016 B
Python
import pytest
|
|
|
|
from clickhouse_connect.driver.binding import quote_identifier
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"identifier, expected",
|
|
[
|
|
("foo", "`foo`"),
|
|
("foo`bar", "`foo\\`bar`"),
|
|
('foo"bar', '`foo"bar`'),
|
|
("", "``"),
|
|
],
|
|
)
|
|
def test_quote_identifier_raw(identifier, expected):
|
|
assert quote_identifier(identifier) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"identifier",
|
|
[
|
|
"`foo`",
|
|
'"foo"',
|
|
"`foo\\`bar`",
|
|
"`foo``bar`",
|
|
'"foo""bar"',
|
|
],
|
|
)
|
|
def test_quote_identifier_valid_prequoted_passthrough(identifier):
|
|
assert quote_identifier(identifier) == identifier
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"identifier, expected",
|
|
[
|
|
("`weird`name`", "`\\`weird\\`name\\``"),
|
|
('"weird"name"', '`"weird"name"`'),
|
|
("`foo\\`", "`\\`foo\\\\\\``"),
|
|
("`", "`\\``"),
|
|
],
|
|
)
|
|
def test_quote_identifier_invalid_prequoted_escaped_as_raw(identifier, expected):
|
|
assert quote_identifier(identifier) == expected
|