collerek
2021-04-23 15:45:35 +02:00
parent ecd613d486
commit 638af9ad4c
7 changed files with 18 additions and 8 deletions

View File

@ -69,5 +69,6 @@ jobs:
uses: codecov/codecov-action@v1
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v2.7.5
if: github.event.pull_request.head.repo.full_name == 'collerek/ormar'
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_COVERAGE_TOKEN }}

View File

@ -1,3 +1,11 @@
# 0.10.5
## 🐛 Fixes
* Fix bug in `fastapi-pagination` [#73](https://github.com/uriyyo/fastapi-pagination/issues/73)
* Remove unnecessary `Optional` in `List[Optional[T]]` in return value for `QuerySet.all()` and `Querysetproxy.all()` return values [#174](https://github.com/collerek/ormar/issues/174)
* Run tests coverage publish only on internal prs instead of all in github action.
# 0.10.4
## ✨ Features

View File

@ -75,7 +75,7 @@ class UndefinedType: # pragma no cover
Undefined = UndefinedType()
__version__ = "0.10.4"
__version__ = "0.10.5"
__all__ = [
"Integer",
"BigInteger",

View File

@ -697,7 +697,7 @@ class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass
if relation_map is not None
else translate_list_to_dict(self._iterate_related_models())
)
pk_only = object.__getattribute__(self, "__pk_only__")
pk_only = getattr(self, "__pk_only__", False)
if relation_map and not pk_only:
dict_instance = self._extract_nested_models(
relation_map=relation_map,

View File

@ -12,6 +12,7 @@ quick_access_set = {
"__fields__",
"__fields_set__",
"__json_encoder__",
"__pk_only__",
"__post_root_validators__",
"__pre_root_validators__",
"__private_attributes__",

View File

@ -137,8 +137,8 @@ class QuerySet(Generic[T]):
)
async def _prefetch_related_models(
self, models: List[Optional["T"]], rows: List
) -> List[Optional["T"]]:
self, models: List["T"], rows: List
) -> List["T"]:
"""
Performs prefetch query for selected models names.
@ -158,7 +158,7 @@ class QuerySet(Generic[T]):
)
return await query.prefetch_related(models=models, rows=rows) # type: ignore
def _process_query_result_rows(self, rows: List) -> List[Optional["T"]]:
def _process_query_result_rows(self, rows: List) -> List["T"]:
"""
Process database rows and initialize ormar Model from each of the rows.
@ -179,7 +179,7 @@ class QuerySet(Generic[T]):
]
if result_rows:
return self.model.merge_instances_list(result_rows) # type: ignore
return cast(List[Optional["T"]], result_rows)
return cast(List["T"], result_rows)
def _resolve_filter_groups(
self, groups: Any
@ -884,7 +884,7 @@ class QuerySet(Generic[T]):
model = await self.get(pk=kwargs[pk_name])
return await model.update(**kwargs)
async def all(self, *args: Any, **kwargs: Any) -> List[Optional["T"]]: # noqa: A003
async def all(self, *args: Any, **kwargs: Any) -> List["T"]: # noqa: A003
"""
Returns all rows from a database for given model for set filter options.

View File

@ -342,7 +342,7 @@ class QuerysetProxy(Generic[T]):
self._register_related(get)
return get
async def all(self, *args: Any, **kwargs: Any) -> List[Optional["T"]]: # noqa: A003
async def all(self, *args: Any, **kwargs: Any) -> List["T"]: # noqa: A003
"""
Returns all rows from a database for given model for set filter options.