From db939802102b7bfe7db8ad8407b11fb526fa42c8 Mon Sep 17 00:00:00 2001 From: Myer Nore Date: Fri, 3 Aug 2018 11:46:57 -0400 Subject: [PATCH 1/4] #9 type error DEMIndex save --- django_elastic_migrations/indexes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django_elastic_migrations/indexes.py b/django_elastic_migrations/indexes.py index 1f98ac3..8642370 100644 --- a/django_elastic_migrations/indexes.py +++ b/django_elastic_migrations/indexes.py @@ -898,6 +898,9 @@ def save(self, using=None): using = es_client try: super(DEMIndex, self).save(using=using) + except TypeError as te: + if "unexpected keyword argument 'using'" in str(te): + super(DEMIndex, self).save() except ValueError as ex: if "Empty value" in ex.message and not self.get_active_version_index_name(): msg = ( From 4b30859ec10da7f78dbe3eca2bf160e521b841ab Mon Sep 17 00:00:00 2001 From: Myer Nore Date: Fri, 3 Aug 2018 13:08:45 -0400 Subject: [PATCH 2/4] add test to ensure that multiple versions of DEM work with DEMIndex.save #9 type error DEMIndex save --- tests/test_indexes.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_indexes.py b/tests/test_indexes.py index cdbda50..804e043 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -6,8 +6,12 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) +from elasticsearch import TransportError +from elasticsearch_dsl.exceptions import IllegalOperation + from django_elastic_migrations import DEMIndexManager from django_elastic_migrations.utils.test_utils import DEMTestCase +from tests.es_config import ES_CLIENT from tests.search import MovieSearchIndex, MovieSearchDoc from tests.models import Movie @@ -34,3 +38,15 @@ def test_update_index(self): results = MovieSearchDoc.get_search(movie_title).execute() first_result = results[0] self.assertEqual(str(movie.id), first_result.meta.id) + + def test_save_index_elasticsearch_dsl_lt_62(self): + """ + Added for #9 type error DEMIndex save + Tests that DEMIndex.save(using=using) works in 6.1 and 6.2 versions of DEM + """ + try: + # if elasticsearch_dsl <= 6.2, using is not a parameter but shouldn't throw exception + MovieSearchIndex.save(using=ES_CLIENT) + except (TransportError, IllegalOperation): + # the indexes already exist + pass From 603e7a4de8fb2ba0cb7a9a633e6016e4d9dd6b4b Mon Sep 17 00:00:00 2001 From: Myer Nore Date: Fri, 3 Aug 2018 13:12:01 -0400 Subject: [PATCH 3/4] bump version to 0.6.1 and update changelog #9 type error DEMIndex save --- CHANGELOG.rst | 4 ++++ django_elastic_migrations/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f1f6e4d..e03f1e0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Changelog --------- +0.6.1 (2018-08-03) +~~~~~~~~~~~~~~~~~~ +* fixed gh #9: "using elasticsearch-dsl 6.1, TypeError in DEMIndex.save" + 0.6.0 (2018-08-01) ~~~~~~~~~~~~~~~~~~ * Added test structure for py2 - GH #2 diff --git a/django_elastic_migrations/__init__.py b/django_elastic_migrations/__init__.py index 5a33ff6..23ef420 100644 --- a/django_elastic_migrations/__init__.py +++ b/django_elastic_migrations/__init__.py @@ -10,7 +10,7 @@ from django_elastic_migrations.utils import loading from django_elastic_migrations.utils.django_elastic_migrations_log import get_logger -__version__ = '0.6.0' +__version__ = '0.6.1' default_app_config = 'django_elastic_migrations.apps.DjangoElasticMigrationsConfig' # pylint: disable=invalid-name From 73639f7a8a102ca9f7476065c108ce18781c6845 Mon Sep 17 00:00:00 2001 From: Myer Nore Date: Fri, 3 Aug 2018 13:33:49 -0400 Subject: [PATCH 4/4] make dependencies more explicit until GH #3 is fixed #9 type error DEMIndex save --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 596c343..2361ef9 100755 --- a/setup.py +++ b/setup.py @@ -49,7 +49,8 @@ def get_version(*file_paths): license='MIT', include_package_data=True, install_requires=[ - "Django>=1.8,<2.1", "elasticsearch-dsl>=6.0.0", "texttable>=1.2.1", + # TBD: GH issue #3 includes support for elasticsearch-dsl>=6.2.0 + "Django>=1.8,<2.1", "elasticsearch-dsl>=6.0.0,<6.2.0", "texttable>=1.2.1", "multiprocessing-logging>=0.2.6" ], zip_safe=False,