Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maps PositiveBigIntegerField field. #55 #67

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)
Loading