clean unused code
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 21.9b0
|
rev: 21.12b0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
exclude: docs_src
|
exclude: docs_src
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import datetime
|
|
||||||
from typing import Any, TYPE_CHECKING, Type
|
from typing import Any, TYPE_CHECKING, Type
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
@ -137,8 +136,6 @@ class FilterAction(QueryAction):
|
|||||||
if isinstance(self.filter_value, ormar.Model):
|
if isinstance(self.filter_value, ormar.Model):
|
||||||
self.filter_value = self.filter_value.pk
|
self.filter_value = self.filter_value.pk
|
||||||
|
|
||||||
# self._convert_dates_if_required()
|
|
||||||
|
|
||||||
op_attr = FILTER_OPERATORS[self.operator]
|
op_attr = FILTER_OPERATORS[self.operator]
|
||||||
if self.operator == "isnull":
|
if self.operator == "isnull":
|
||||||
op_attr = "is_" if self.filter_value else "isnot"
|
op_attr = "is_" if self.filter_value else "isnot"
|
||||||
@ -156,20 +153,3 @@ class FilterAction(QueryAction):
|
|||||||
if self.has_escaped_character:
|
if self.has_escaped_character:
|
||||||
clause.modifiers["escape"] = "\\"
|
clause.modifiers["escape"] = "\\"
|
||||||
return clause
|
return clause
|
||||||
|
|
||||||
def _convert_dates_if_required(self) -> None:
|
|
||||||
"""
|
|
||||||
Converts dates, time and datetime to isoformat
|
|
||||||
"""
|
|
||||||
if isinstance(
|
|
||||||
self.filter_value, (datetime.date, datetime.time, datetime.datetime)
|
|
||||||
):
|
|
||||||
self.filter_value = self.filter_value.isoformat()
|
|
||||||
|
|
||||||
if isinstance(self.filter_value, (list, tuple, set)):
|
|
||||||
self.filter_value = [
|
|
||||||
x.isoformat()
|
|
||||||
if isinstance(x, (datetime.date, datetime.time, datetime.datetime))
|
|
||||||
else x
|
|
||||||
for x in self.filter_value
|
|
||||||
]
|
|
||||||
|
|||||||
@ -79,7 +79,6 @@ class AliasManager:
|
|||||||
"""
|
"""
|
||||||
alias = f"{alias}_" if alias else ""
|
alias = f"{alias}_" if alias else ""
|
||||||
aliased_fields = [f"{alias}{x}" for x in fields] if fields else []
|
aliased_fields = [f"{alias}{x}" for x in fields] if fields else []
|
||||||
# TODO: check if normal fields still needed or only aliased one
|
|
||||||
all_columns = (
|
all_columns = (
|
||||||
table.columns
|
table.columns
|
||||||
if not fields
|
if not fields
|
||||||
|
|||||||
@ -130,13 +130,14 @@ async def test_query_with_time_in_filter():
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_filtering_by_timezone_with_timedelta():
|
async def test_filtering_by_timezone_with_timedelta():
|
||||||
now_utc = datetime.now(timezone.utc)
|
async with database:
|
||||||
object = MyModel(created_at=now_utc)
|
now_utc = datetime.now(timezone.utc)
|
||||||
await object.save()
|
object = MyModel(created_at=now_utc)
|
||||||
|
await object.save()
|
||||||
|
|
||||||
one_hour_ago = datetime.now(timezone.utc) - timedelta(hours=1)
|
one_hour_ago = datetime.now(timezone.utc) - timedelta(hours=1)
|
||||||
created_since_one_hour_ago = await MyModel.objects.filter(
|
created_since_one_hour_ago = await MyModel.objects.filter(
|
||||||
created_at__gte=one_hour_ago
|
created_at__gte=one_hour_ago
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
assert len(created_since_one_hour_ago) == 1
|
assert len(created_since_one_hour_ago) == 1
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class DataSourceTableColumn(ormar.Model):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="module")
|
@pytest.fixture(autouse=True, scope="module")
|
||||||
def create_test_database():
|
def create_test_database(): # pragma: no cover
|
||||||
engine = sqlalchemy.create_engine(DATABASE_URL)
|
engine = sqlalchemy.create_engine(DATABASE_URL)
|
||||||
metadata.drop_all(engine)
|
metadata.drop_all(engine)
|
||||||
metadata.create_all(engine)
|
metadata.create_all(engine)
|
||||||
@ -61,7 +61,7 @@ def create_test_database():
|
|||||||
reason="wait for fix for sqlite in encode/databases",
|
reason="wait for fix for sqlite in encode/databases",
|
||||||
)
|
)
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_double_nested_reverse_relation():
|
async def test_double_nested_reverse_relation(): # pragma: no cover
|
||||||
async with database:
|
async with database:
|
||||||
data_source = await DataSource(name="local").save()
|
data_source = await DataSource(name="local").save()
|
||||||
test_tables = [
|
test_tables = [
|
||||||
|
|||||||
Reference in New Issue
Block a user