From 95d2af727d4139546ed1b875bf8f97e1eb0414f5 Mon Sep 17 00:00:00 2001 From: Mariano ramirez Date: Mon, 8 Jan 2024 18:46:57 -0400 Subject: [PATCH] Fix issue with index on Search names for PostgreSQL (#287) * Make postgres as default False with INDEX_SEARCH_NAMES * docs * QA modifications and TODO * qa * qa * qa * qa * W503 fix for qa --- README.rst | 7 +++++++ src/cities_light/settings.py | 15 ++++++++++++--- tox.ini | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index bddbb441..accc6f70 100644 --- a/README.rst +++ b/README.rst @@ -168,6 +168,13 @@ If you want to build the docs, use the following steps:: cd docs make html +TODOS +----- + +- Add ruff for formatting +- Improve the performance of the import command +- Improve the local development environment with https://tox.wiki/en/legacy/example/devenv.html + Resources --------- diff --git a/src/cities_light/settings.py b/src/cities_light/settings.py index e521c683..e6f97fcf 100644 --- a/src/cities_light/settings.py +++ b/src/cities_light/settings.py @@ -83,11 +83,18 @@ .. py:data:: INDEX_SEARCH_NAMES - If your database engine for cities_light supports indexing TextFields (ie. - it is **not** MySQL), then this should be set to True. You might have to + If your database engine for cities_light supports indexing TextFields, + then this should be set to True. You might have to override this setting with ``settings.CITIES_LIGHT_INDEX_SEARCH_NAMES`` if using several databases for your project. + Notes: + - MySQL doesn't support indexing TextFields. + - PostgreSQL supports indexing TextFields, but it is not enabled by default + in cities_light because the lenght of the field can be too long for btree + for more information please visit #273 + + .. py:data:: CITIES_LIGHT_APP_NAME Modify it only if you want to define your custom cities models, that @@ -147,7 +154,9 @@ if INDEX_SEARCH_NAMES is None: INDEX_SEARCH_NAMES = True for database in list(settings.DATABASES.values()): - if "ENGINE" in database and 'mysql' in database.get('ENGINE').lower(): + if "ENGINE" in database and ( + 'mysql' in database.get('ENGINE').lower() or + 'postgresql' in database.get('ENGINE').lower()): INDEX_SEARCH_NAMES = False DEFAULT_APP_NAME = 'cities_light' diff --git a/tox.ini b/tox.ini index f4870ad0..363273c1 100644 --- a/tox.ini +++ b/tox.ini @@ -85,7 +85,7 @@ passenv = [testenv:checkqa] basepython = python3.8 -commands = pycodestyle --ignore=E402,E124,E128 --exclude=tests,migrations src/cities_light +commands = pycodestyle --ignore=E402,E124,E128,W503,W504 --exclude=tests,migrations src/cities_light deps = pycodestyle [testenv:pylint]