Files
Joe SpadolaandGitHub 242b7e7aa2 fix unescaped inner quotes in pre-quoted identifiers (#750)
* fix unescaped inner quotes in pre-quoted identifiers

* update misleading comment
2026-05-20 14:00:57 -07:00

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