Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Jun 7, 2024
1 parent cf9e2ab commit fae03ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions muffin_rest/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Filter(Mutate):
"$nor": lambda v, c: not any(f(v, c) for f in v),
}
operators["<"] = operators["$lt"]
operators["<="] = operators["$le"]
operators["<="] = operators["$lte"] = operators["$le"]
operators[">"] = operators["$gt"]
operators[">="] = operators["$ge"]
operators[">="] = operators["$gte"] = operators["$ge"]
operators["=="] = operators["$eq"]
operators["!="] = operators["$ne"]
operators["<<"] = operators["$in"]
Expand Down
6 changes: 3 additions & 3 deletions muffin_rest/peewee/options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Type
from typing import Type

import peewee as pw
from marshmallow_peewee import ModelSchema
Expand Down Expand Up @@ -27,7 +27,7 @@ class PWRESTOptions(RESTOptions):
base_property: str = "model"

model: Type[pw.Model]
model_pk: Optional[pw.Field] = None
model_pk: pw.Field

manager: Manager

Expand All @@ -38,7 +38,7 @@ def setup(self, cls):
"""Prepare meta options."""
meta = self.model._meta # type: ignore[]
self.name = self.name or meta.table_name.lower()
self.model_pk = self.model_pk or meta.primary_key
self.model_pk = getattr(self, "model_pk", None) or meta.primary_key
manager = getattr(self, "manager", getattr(self.model, "_manager", None))
if manager is None:
raise RuntimeError("Peewee-AIO ORM Manager is not available")
Expand Down
4 changes: 2 additions & 2 deletions muffin_rest/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SARESTOptions(RESTOptions):
schema_base: Type[SQLAlchemyAutoSchema] = SQLAlchemyAutoSchema

table: sa.Table
table_pk: Optional[sa.Column] = None
table_pk: sa.Column
database: Database

base_property = "table"
Expand All @@ -88,7 +88,7 @@ def setup(self, cls):
raise ValueError("'SARESTHandler.Meta.database' is required")

self.name = self.name or self.table.name
self.table_pk = self.table_pk or self.table.c.id
self.table_pk = getattr(self, "table_pk", None) or self.table.c.id

super().setup(cls)

Expand Down

0 comments on commit fae03ac

Please sign in to comment.