Skip to content
Open
9 changes: 4 additions & 5 deletions mapit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@


def materialized():
version = connection.cursor().connection.server_version
materialized = ''
if version >= 120000:
if connection.pg_version >= 120000:
materialized = 'MATERIALIZED'
return materialized

Expand Down Expand Up @@ -191,8 +190,8 @@ def intersect(self, query_type, area, types, generation):
params = [area.id, area.id, generation.id, generation.id]

if types:
params.append(tuple(types))
query_area_type = ' AND mapit_area.type_id IN (SELECT id FROM mapit_type WHERE code IN %s) '
params.append(list(types))
query_area_type = ' AND mapit_area.type_id IN (SELECT id FROM mapit_type WHERE code = ANY(%s)) '
else:
query_area_type = ''

Expand Down Expand Up @@ -452,7 +451,7 @@ def filter_by_area(self, area, limit=''):
WHERE area_id = %s'''
query = '''
WITH target AS %s ( %s )
SELECT "mapit_postcode"."id", "mapit_postcode"."postcode", "mapit_postcode"."location"::bytea
SELECT "mapit_postcode"."id", "mapit_postcode"."postcode", "mapit_postcode"."location"
FROM mapit_postcode, target
WHERE ST_CoveredBy(location, target.division)
%s
Expand Down
2 changes: 1 addition & 1 deletion mapit/views/areas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from psycopg2 import InternalError
from django.db import InternalError
from django.db.utils import DatabaseError

from django.utils.translation import gettext as _
Expand Down
2 changes: 1 addition & 1 deletion mapit_gb/management/commands/mapit_UK_add_ons_to_gss.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
from django.core.management.base import BaseCommand
from mapit.models import Area, CodeType
from psycopg2 import IntegrityError
from django.db import IntegrityError

python_version = sys.version_info[0]

Expand Down
2 changes: 1 addition & 1 deletion mapit_gb/management/commands/mapit_UK_update_ons_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import csv
from django.core.management.base import BaseCommand
from mapit.models import Area, Generation, CodeType
from psycopg2 import IntegrityError
from django.db import IntegrityError


class Command(BaseCommand):
Expand Down
2 changes: 1 addition & 1 deletion mapit_gb/management/commands/mapit_UK_update_ons_ids2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import csv
from django.core.management.base import BaseCommand
from mapit.models import Area, Generation, CodeType
from psycopg2 import IntegrityError
from django.db import IntegrityError


class Command(BaseCommand):
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ def read_file(filename):
install_requires=[
'Django >= 4.2, <6.0',
'libsass >= 0.13.3',
'psycopg2',
'PyYAML',
'Shapely',
'uk-postcode-utils',
],
extras_require={
'psycopg': ['psycopg'],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ envlist = flake8, py310-{4.2,5.2}
commands =
flake8: flake8 mapit mapit_gb mapit_it mapit_no mapit_se mapit_za project
py310: python -W all -W ignore::PendingDeprecationWarning -m coverage run --source mapit manage.py test mapit mapit_gb
extras =
py310: psycopg
deps =
py310: coverage
flake8: flake8
Expand Down
Loading