Skip to content

Commit

Permalink
Fix issue with index on Search names for PostgreSQL (#287)
Browse files Browse the repository at this point in the history
* Make postgres as default False with INDEX_SEARCH_NAMES

* docs

* QA modifications and TODO

* qa

* qa

* qa

* qa

* W503 fix for qa
  • Loading branch information
marianoeramirez committed Jan 8, 2024
1 parent 02c9388 commit 95d2af7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------

Expand Down
15 changes: 12 additions & 3 deletions src/cities_light/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 95d2af7

Please sign in to comment.