Skip to content

Commit f003567

Browse files
committed
feat: import escape_string from tortoise
1 parent dbf807e commit f003567

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

fastapi_esql/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from logging.config import dictConfig
22

3+
from tortoise.converters import escape_string
34
from tortoise.queryset import Q
45

56
from .const import (
@@ -36,6 +37,7 @@
3637
"SQLizer",
3738
"Singleton",
3839
"convert_dicts",
40+
"escape_string",
3941
"timing",
4042
]
4143

tests/test_converter.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from json import loads
33
from unittest import TestCase
44

5-
from fastapi_esql import convert_dicts
5+
from fastapi_esql import convert_dicts, escape_string
66

77

88
class TestConvertDicts(TestCase):
@@ -23,3 +23,11 @@ def test_wrong_converter(self):
2323
dicts = deepcopy(self.dicts)
2424
convert_dicts(dicts, {"value": int})
2525
assert dicts == [{"id": 1, "value": 1}, {"id": 2, "value": '{"k": [true, null]}'}]
26+
27+
28+
class TestEscapeString(TestCase):
29+
30+
def test_normal(self):
31+
assert escape_string("'") == "\\'"
32+
assert escape_string('"') == '\\"'
33+
assert escape_string('\\') == '\\\\'

0 commit comments

Comments
 (0)