Skip to content

Commit 95d2af7

Browse files
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
1 parent 02c9388 commit 95d2af7

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ If you want to build the docs, use the following steps::
168168
cd docs
169169
make html
170170

171+
TODOS
172+
-----
173+
174+
- Add ruff for formatting
175+
- Improve the performance of the import command
176+
- Improve the local development environment with https://tox.wiki/en/legacy/example/devenv.html
177+
171178
Resources
172179
---------
173180

src/cities_light/settings.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@
8383
8484
.. py:data:: INDEX_SEARCH_NAMES
8585
86-
If your database engine for cities_light supports indexing TextFields (ie.
87-
it is **not** MySQL), then this should be set to True. You might have to
86+
If your database engine for cities_light supports indexing TextFields,
87+
then this should be set to True. You might have to
8888
override this setting with ``settings.CITIES_LIGHT_INDEX_SEARCH_NAMES`` if
8989
using several databases for your project.
9090
91+
Notes:
92+
- MySQL doesn't support indexing TextFields.
93+
- PostgreSQL supports indexing TextFields, but it is not enabled by default
94+
in cities_light because the lenght of the field can be too long for btree
95+
for more information please visit #273
96+
97+
9198
.. py:data:: CITIES_LIGHT_APP_NAME
9299
93100
Modify it only if you want to define your custom cities models, that
@@ -147,7 +154,9 @@
147154
if INDEX_SEARCH_NAMES is None:
148155
INDEX_SEARCH_NAMES = True
149156
for database in list(settings.DATABASES.values()):
150-
if "ENGINE" in database and 'mysql' in database.get('ENGINE').lower():
157+
if "ENGINE" in database and (
158+
'mysql' in database.get('ENGINE').lower() or
159+
'postgresql' in database.get('ENGINE').lower()):
151160
INDEX_SEARCH_NAMES = False
152161

153162
DEFAULT_APP_NAME = 'cities_light'

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ passenv =
8585

8686
[testenv:checkqa]
8787
basepython = python3.8
88-
commands = pycodestyle --ignore=E402,E124,E128 --exclude=tests,migrations src/cities_light
88+
commands = pycodestyle --ignore=E402,E124,E128,W503,W504 --exclude=tests,migrations src/cities_light
8989
deps = pycodestyle
9090

9191
[testenv:pylint]

0 commit comments

Comments
 (0)