Metadata-Version: 2.1
Name: fastapi-sqlalchemy-filter
Version: 0.1.0
Summary: A simple FastAPI filter for SQLAlchemy
Home-page: https://github.com/waruingugi/fastapi-filter-sqlalchemy-lite
License: MIT
Author: Arthur Rio
Author-email: arthur.rio44@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Framework :: FastAPI
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: fastapi (>=0.78,<0.93)
Requires-Dist: pydantic (>=1.10.0,<2.0.0)
Requires-Dist: sqlalchemy (>=1.4.36,<2.1.0)
Project-URL: Repository, https://github.com/waruingugi/fastapi-filter-sqlalchemy-lite
Description-Content-Type: text/markdown

# FastAPI filter

## Compatibility

**Required:**
  * Python: >=3.8, <3.12
  * Fastapi: >=0.78, <0.93
  * Pydantic: >=1.10.0, <2.0.0


**Optional**
  * SQLAlchemy: >=1.4.36, <2.1.0

## Installation
---

```bash
# Lite version
pip install fastapi-sqlalchemy-filter-lite
```

## Documentation
---
This package was inspired by [arthurio](https://github.com/arthurio/fastapi-filter)  

The package is a lite version for **SQLAlchemy only** with a few modifications to it.

Please visit this site to view the full documentation: [https://fastapi-filter.netlify.app/](https://fastapi-filter.netlify.app/)

## Modifications / Additions
---
### You can import the `Filter` class and create a filter on the fly:
```bash
from fastapi_sqlalchemy_filter import Filter

user_dict = {'name': 'Jon Snow', 'clan': 'Targaryen'}
user_filter = Filter(**user_dict)
```

### Package returns `None` if an ordering field is not present on the class definition.
### *Note: No user action is needed on this part*
This function was modified from:
```bash
...
    @property
    def ordering_values(self):
        """Check that the ordering field is present on the class definition."""
        try:
            return getattr(self, self.Constants.ordering_field_name)
        except AttributeError:
            raise AttributeError(
                f"Ordering field {self.Constants.ordering_field_name} is not defined. "
                "Make sure to add it to your filter class."
            )
...
```

To
```bash
...
    @property
    def ordering_values(self):
        """Check that the ordering field is present on the class definition."""
        if hasattr(self, self.Constants.ordering_field_name):
            return getattr(self, self.Constants.ordering_field_name)
        return None
...
```
