Skip to content

Commit

Permalink
Maps PositiveBigIntegerField field. #55
Browse files Browse the repository at this point in the history
  • Loading branch information
jlariza authored and qcoumes committed Apr 22, 2024
1 parent 88bb79b commit 327f0d1
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions django_opensearch_dsl/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
models.ImageField: fields.FileField,
models.IntegerField: fields.IntegerField,
models.NullBooleanField: fields.BooleanField,
models.PositiveBigIntegerField: fields.LongField,
models.PositiveIntegerField: fields.IntegerField,
models.PositiveSmallIntegerField: fields.ShortField,
models.SlugField: fields.KeywordField,
Expand Down Expand Up @@ -60,10 +61,18 @@ def __init__(self, related_instance_to_ignore=None, **kwargs):
def search(cls, using=None, index=None):
"""Return a `Search` object parametrized with the index' information."""
return Search(
using=cls._get_using(using), index=cls._default_index(index), doc_type=[cls], model=cls.django.model
using=cls._get_using(using),
index=cls._default_index(index),
doc_type=[cls],
model=cls.django.model,
)

def get_queryset(self, filter_: Optional[Q] = None, exclude: Optional[Q] = None, count: int = None) -> QuerySet:
def get_queryset(
self,
filter_: Optional[Q] = None,
exclude: Optional[Q] = None,
count: int = None,
) -> QuerySet:
"""Return the queryset that should be indexed by this doc type."""
qs = self.django.model.objects.all()

Expand Down Expand Up @@ -144,7 +153,10 @@ def init_prepare(self):
if prep_func:
fn = prep_func
else:
fn = partial(field.get_value_from_instance, field_value_to_ignore=self._related_instance_to_ignore)
fn = partial(
field.get_value_from_instance,
field_value_to_ignore=self._related_instance_to_ignore,
)

preparers.append((name, field, fn))

Expand Down Expand Up @@ -233,4 +245,10 @@ def update(self, thing, action, *args, refresh=None, using=None, **kwargs): # n
else:
object_list = thing

return self._bulk(self._get_actions(object_list, action), *args, refresh=refresh, using=using, **kwargs)
return self._bulk(
self._get_actions(object_list, action),
*args,
refresh=refresh,
using=using,
**kwargs,
)

0 comments on commit 327f0d1

Please sign in to comment.