diff --git a/ormar/fields/foreign_key.py b/ormar/fields/foreign_key.py index b457616..ae6745c 100644 --- a/ormar/fields/foreign_key.py +++ b/ormar/fields/foreign_key.py @@ -111,7 +111,6 @@ class ForeignKeyField(BaseField): def expand_relationship( cls, value: Any, child: "Model" ) -> Optional[Union["Model", List["Model"]]]: - print("expandong relatiknship", value, child) if value is None: return None diff --git a/ormar/models/fakepydantic.py b/ormar/models/fakepydantic.py index 44dd97f..c44309d 100644 --- a/ormar/models/fakepydantic.py +++ b/ormar/models/fakepydantic.py @@ -171,9 +171,7 @@ class FakePydantic(pydantic.BaseModel, metaclass=ModelMetaclass): exclude_defaults: bool = False, exclude_none: bool = False, nested: bool = False - ) -> 'DictStrAny': # noqa: A003 - print('callin super', self.__class__) - print('to exclude', self._exclude_related_names_not_required(nested)) + ) -> 'DictStrAny': # noqa: A003' dict_instance = super().dict(include=include, exclude=self._exclude_related_names_not_required(nested), by_alias=by_alias, @@ -181,9 +179,7 @@ class FakePydantic(pydantic.BaseModel, metaclass=ModelMetaclass): exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none) - print('after super') for field in self._extract_related_names(): - print(self.__class__, field, nested) nested_model = getattr(self, field) if self.Meta.model_fields[field].virtual and nested: @@ -191,13 +187,9 @@ class FakePydantic(pydantic.BaseModel, metaclass=ModelMetaclass): if isinstance(nested_model, list) and not isinstance( nested_model, ormar.Model ): - print('nested list') dict_instance[field] = [x.dict(nested=True) for x in nested_model] - else: - print('instance') - if nested_model is not None: - dict_instance[field] = nested_model.dict(nested=True) - + elif nested_model is not None: + dict_instance[field] = nested_model.dict(nested=True) return dict_instance def from_dict(self, value_dict: Dict) -> None: diff --git a/ormar/models/metaclass.py b/ormar/models/metaclass.py index 1d4044b..56d66d9 100644 --- a/ormar/models/metaclass.py +++ b/ormar/models/metaclass.py @@ -113,11 +113,9 @@ def populate_pydantic_default_values(attrs: Dict) -> Dict: type_.name = field def_value = type_.default_value() curr_def_value = attrs.get(field, 'NONE') - print(field, curr_def_value, 'def val', type_.nullable) if curr_def_value == 'NONE' and isinstance(def_value, FieldInfo): attrs[field] = def_value elif curr_def_value == 'NONE' and type_.nullable: - print(field, 'defsults tp none') attrs[field] = FieldInfo(default=None) return attrs @@ -147,8 +145,6 @@ class ModelMetaclass(pydantic.main.ModelMetaclass): annotations = attrs.get("__annotations__") or new_model.__annotations__ attrs["__annotations__"]= annotations attrs = populate_pydantic_default_values(attrs) - - print(attrs) tablename = name.lower() + "s" new_model.Meta.tablename = new_model.Meta.tablename or tablename @@ -182,8 +178,6 @@ class ModelMetaclass(pydantic.main.ModelMetaclass): ) new_model.Meta.model_fields = model_fields - print(attrs, 'before super') - print(new_model.Meta.__dict__) new_model = super().__new__( # type: ignore mcs, name, bases, attrs ) diff --git a/ormar/queryset/query.py b/ormar/queryset/query.py index 798502a..30b739e 100644 --- a/ormar/queryset/query.py +++ b/ormar/queryset/query.py @@ -79,7 +79,7 @@ class Query: expr = self._apply_expression_modifiers(expr) - print(expr.compile(compile_kwargs={"literal_binds": True})) + #print(expr.compile(compile_kwargs={"literal_binds": True})) self._reset_query_parameters() return expr, self._select_related @@ -179,7 +179,6 @@ class Query: ): rel_part = field_name if not rel_part else rel_part + "__" + field_name if not field.nullable: - print('add', rel_part, field) if rel_part not in self._select_related: new_related = "__".join(rel_part.split("__")[:-1]) if len( rel_part.split("__")) > 1 else rel_part @@ -188,7 +187,7 @@ class Query: elif self._field_qualifies_to_deeper_search( field, parent_virtual, nested, rel_part ): - print('deeper', rel_part, field, field.to) + self._extract_auto_required_relations( prev_model=field.to, rel_part=rel_part, diff --git a/ormar/relations.py b/ormar/relations.py index 2177ac0..8a422d9 100644 --- a/ormar/relations.py +++ b/ormar/relations.py @@ -69,10 +69,8 @@ class RelationshipManager: @staticmethod def append_related_model(relations_list: List["Model"], model: "Model") -> None: - print("appending", relations_list, model) for relation_child in relations_list: try: - print(relation_child.__same__(model), "same") if relation_child.__same__(model): return except ReferenceError: diff --git a/tests/test_foreign_keys.py b/tests/test_foreign_keys.py index e37a3fd..17e4a52 100644 --- a/tests/test_foreign_keys.py +++ b/tests/test_foreign_keys.py @@ -117,9 +117,6 @@ async def test_model_crud(): await track1.save() await track2.save() await track3.save() - - assert len(album.tracks) == 3 - assert album.tracks[1].title == "Heart don't stand a chance" track = await Track.objects.get(title="The Bird") assert track.album.pk == album.pk @@ -127,6 +124,8 @@ async def test_model_crud(): await track.album.load() assert track.album.name == "Malibu" + assert len(album.tracks) == 3 + assert album.tracks[1].title == "Heart don't stand a chance" album1 = await Album.objects.get(name="Malibu") assert album1.pk == 1