Skip to content

Commit

Permalink
fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mstingl committed Sep 29, 2024
1 parent 6e965b8 commit 528e017
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions djfapi/routing/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
from datetime import date
from enum import Enum
from functools import cached_property, wraps
from typing import (Any, Dict, Generator, Iterable, List, Optional, Tuple,
Type, TypeVar, Union)
from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple, Type, TypeVar, Union

import forge
from django.db import connections, models
from django.db.transaction import atomic
from djdantic.schemas import Access, Error
from djdantic.schemas.access import AccessScope
from djdantic.utils.dict import remove_none
from djdantic.utils.pydantic import (IdAddedModel, OptionalModel,
ReferencedModel, id_added_model,
include_reference, optional_model)
from djdantic.utils.pydantic import (
IdAddedModel,
OptionalModel,
ReferencedModel,
id_added_model,
include_reference,
optional_model,
)
from djdantic.utils.pydantic_django import TransferAction, transfer_to_orm
from djdantic.utils.typing import get_field_type
from fastapi import (APIRouter, Body, Depends, Path, Query, Request, Response,
Security)
from fastapi import APIRouter, Body, Depends, Path, Query, Request, Response, Security
from fastapi._compat import _normalize_errors
from fastapi.dependencies.utils import analyze_param, request_params_to_args
from fastapi.exceptions import RequestValidationError
Expand All @@ -29,10 +32,8 @@
from ..exceptions import AccessError, ValidationError
from ..schemas import errors as error_schemas
from ..utils.fastapi import Pagination, depends_pagination
from ..utils.fastapi_django import (AggregateResponse, AggregationFunction,
aggregation, request_signalling)
from . import ( # noqa # import SecurityScopes for user friendly import
Method, RouterSchema, SecurityScopes)
from ..utils.fastapi_django import AggregateResponse, AggregationFunction, aggregation, request_signalling
from . import Method, RouterSchema, SecurityScopes # noqa # import SecurityScopes for user friendly import
from .base import TBaseModel, TCreateModel, TUpdateModel
from .registry import register_router

Expand Down Expand Up @@ -720,15 +721,15 @@ def search_filter_fields(
value=Query(**options),
is_path_param=False,
)
fields[name] = getattr(param, 'field') or param[2]
fields[name] = getattr(param, 'field', None) or param[2]

param_not = analyze_param(
param_name=f'not__{name}',
annotation=Optional[type_],
value=Query(**{**options, 'alias': '!' + options.get('alias', name)}),
is_path_param=False,
)
fields[f'not__{name}'] = getattr(param_not, 'field') or param_not[2]
fields[f'not__{name}'] = getattr(param_not, 'field', None) or param_not[2]

return fields

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = djfapi
version = 0.0.72b22
version = 0.0.72b23
author = Manuel Stingl
author_email = [email protected]
description = Utilities for use with FastAPI and django
Expand Down

0 comments on commit 528e017

Please sign in to comment.