-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix copying registry & models. Fix relationships among tenancy object…
…s. (#259) Changes: - fix copying registry+tests - M2M-Field `create_through_model` allows now the keyword only argument `replace_related_field`. - `add_to_registry` has now an additional keyword `replace_related_field_m2m` for seperate controlling the `create_through_model` registration logic. - `add_to_registry` has at most one positional argument. It was intended this way but not enforced. - `create_edgy_model` passes through additional keyword arguments to the edgy model class. - add on_conflict for handling model conflicts - fix invalidation causing _db_schemas removed - instead of passing down keyword arguments from create_edgy_model to type add an argument matching the other behaviour - fix foreign keys with tenancy
- Loading branch information
Showing
36 changed files
with
1,311 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import edgy | ||
|
||
models = ... | ||
|
||
|
||
class Foo(edgy.Model, on_conflict="keep"): | ||
class Meta: | ||
registry = models | ||
|
||
|
||
# or | ||
|
||
|
||
class Foo2(edgy.Model): | ||
class Meta: | ||
registry = False | ||
|
||
|
||
Foo2.add_to_registry(models, name="Foo", on_conflict="replace") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
from typing import ClassVar | ||
from typing import TYPE_CHECKING, Any, ClassVar | ||
|
||
import edgy | ||
|
||
from .metaclasses import AutoReflectionMeta, AutoReflectionMetaInfo | ||
|
||
if TYPE_CHECKING: | ||
from edgy.core.db.models.types import BaseModelType | ||
|
||
|
||
class AutoReflectModel(edgy.ReflectModel, metaclass=AutoReflectionMeta): | ||
meta: ClassVar[AutoReflectionMetaInfo] | ||
|
||
@classmethod | ||
def real_add_to_registry(cls, **kwargs: Any) -> type["BaseModelType"]: | ||
if isinstance(cls.meta, AutoReflectionMetaInfo): | ||
kwargs.setdefault("registry_type_name", "pattern_models") | ||
return super().real_add_to_registry(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.