diff --git a/ormar/fields/base.py b/ormar/fields/base.py index 95645c0..155b1c9 100644 --- a/ormar/fields/base.py +++ b/ormar/fields/base.py @@ -93,9 +93,11 @@ class BaseField(FieldInfo): :rtype: bool """ return ( - field_name not in ["default", "default_factory", "alias"] - and not field_name.startswith("__") - and hasattr(cls, field_name) + field_name not in ["default", "default_factory", "alias", + "allow_mutation"] + and not field_name.startswith("__") + and hasattr(cls, field_name) + and not callable(getattr(cls, field_name)) ) @classmethod @@ -204,7 +206,7 @@ class BaseField(FieldInfo): :rtype: bool """ return cls.default is not None or ( - cls.server_default is not None and use_server + cls.server_default is not None and use_server ) @classmethod @@ -237,7 +239,7 @@ class BaseField(FieldInfo): ondelete=con.ondelete, onupdate=con.onupdate, name=f"fk_{cls.owner.Meta.tablename}_{cls.to.Meta.tablename}" - f"_{cls.to.get_column_alias(cls.to.Meta.pkname)}_{cls.name}", + f"_{cls.to.get_column_alias(cls.to.Meta.pkname)}_{cls.name}", ) for con in cls.constraints ] @@ -270,10 +272,10 @@ class BaseField(FieldInfo): @classmethod def expand_relationship( - cls, - value: Any, - child: Union["Model", "NewBaseModel"], - to_register: bool = True, + cls, + value: Any, + child: Union["Model", "NewBaseModel"], + to_register: bool = True, ) -> Any: """ Function overwritten for relations, in basic field the value is returned as is. @@ -301,7 +303,7 @@ class BaseField(FieldInfo): :rtype: None """ if cls.owner is not None and ( - cls.owner == cls.to or cls.owner.Meta == cls.to.Meta + cls.owner == cls.to or cls.owner.Meta == cls.to.Meta ): cls.self_reference = True cls.self_reference_primary = cls.name diff --git a/setup.py b/setup.py index 909a738..2c5c25b 100644 --- a/setup.py +++ b/setup.py @@ -52,8 +52,11 @@ setup( package_data={PACKAGE: ["py.typed"]}, include_package_data=True, zip_safe=False, + python_requires=">=3.6", data_files=[("", ["LICENSE.md"])], - install_requires=["databases", "pydantic>=1.5", "sqlalchemy", "typing_extensions"], + install_requires=["databases>=0.3.2,<=0.4.1", "pydantic>=1.6.1,<=1.8", + "sqlalchemy>=1.3.18,<=1.3.23", + "typing_extensions>=3.7,<=3.7.4.3"], extras_require={ "postgresql": ["asyncpg", "psycopg2"], "mysql": ["aiomysql", "pymysql"],