Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PiccoloCRUD accepts visible_columns #96

Merged
merged 3 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion piccolo_api/crud/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(
page_size: int = 15,
exclude_secrets: bool = True,
validators: Validators = Validators(),
schema_extra: t.Dict[str, t.Any] = {},
) -> None:
"""
:param table:
Expand All @@ -109,13 +110,17 @@ def __init__(
:param validators:
Used to provide extra validation on certain endpoints - can be
easier than subclassing.
:param schema_extra:
Additional information included in the Pydantic schema.

"""
self.table = table
self.page_size = page_size
self.read_only = read_only
self.allow_bulk_delete = allow_bulk_delete
self.exclude_secrets = exclude_secrets
self.validators = validators
self.schema_extra = schema_extra

root_methods = ["GET"]
if not read_only:
Expand Down Expand Up @@ -158,7 +163,9 @@ def pydantic_model(self) -> t.Type[pydantic.BaseModel]:
Useful for serialising inbound data from POST and PUT requests.
"""
return create_pydantic_model(
self.table, model_name=f"{self.table.__name__}In"
self.table,
model_name=f"{self.table.__name__}In",
**self.schema_extra,
)

def _pydantic_model_output(
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Jinja2>=2.11.0
piccolo[postgres]>=0.46.0
piccolo[postgres]>=0.58.0
pydantic>=1.6
python-multipart>=0.0.5
fastapi>=0.58.0
Expand Down