Skip to content

Commit

Permalink
Move check to the saving part of the products.
Browse files Browse the repository at this point in the history
This will make it possible to use other parts of this package without having to use django 4 or postgres
  • Loading branch information
viggo-devries committed Jan 26, 2024
1 parent 7955f12 commit 4569ac2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
3 changes: 0 additions & 3 deletions oscar_odin/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ def ready(self):

# Register the Django model field resolver
registration.register_field_resolver(ModelFieldResolver, Model)

# pylint: disable=W0611
from .checks import odin_startup_check
23 changes: 0 additions & 23 deletions oscar_odin/checks.py

This file was deleted.

10 changes: 9 additions & 1 deletion oscar_odin/mappings/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,20 @@ def bulk_update_or_create_foreign_keys(self):
Model.objects.bulk_update(instances, fields=fields)

def bulk_update_or_create_instances(self, instances):
instances_to_create, instances_to_update = separate_instances_to_create_and_update(
(
instances_to_create,
instances_to_update,
) = separate_instances_to_create_and_update(
self.Model, instances, self.identifier_mapping
)

validated_create_instances = self.validate_instances(instances_to_create)
self.Model.objects.bulk_create(validated_create_instances)
for instance in validated_create_instances:
if instance.pk is None:
raise OscarOdinException(
"django-oscar-odin does not support sqlite3 with Django < 4. Please use engines that have can_return_rows_from_bulk_insert set to True (like Postgres) or upgrade your Django version to 4 or higher."
)

fields = self.get_fields_to_update(self.Model)
if fields is not None:
Expand Down

0 comments on commit 4569ac2

Please sign in to comment.