Skip to content

Commit

Permalink
feat: import escape_string from tortoise
Browse files Browse the repository at this point in the history
  • Loading branch information
NightMarcher committed Aug 18, 2023
1 parent dbf807e commit f003567
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions fastapi_esql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from logging.config import dictConfig

from tortoise.converters import escape_string
from tortoise.queryset import Q

from .const import (
Expand Down Expand Up @@ -36,6 +37,7 @@
"SQLizer",
"Singleton",
"convert_dicts",
"escape_string",
"timing",
]

Expand Down
10 changes: 9 additions & 1 deletion tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from json import loads
from unittest import TestCase

from fastapi_esql import convert_dicts
from fastapi_esql import convert_dicts, escape_string


class TestConvertDicts(TestCase):
Expand All @@ -23,3 +23,11 @@ def test_wrong_converter(self):
dicts = deepcopy(self.dicts)
convert_dicts(dicts, {"value": int})
assert dicts == [{"id": 1, "value": 1}, {"id": 2, "value": '{"k": [true, null]}'}]


class TestEscapeString(TestCase):

def test_normal(self):
assert escape_string("'") == "\\'"
assert escape_string('"') == '\\"'
assert escape_string('\\') == '\\\\'

0 comments on commit f003567

Please sign in to comment.