acdh-oeaw / apis-core

https://acdh-oeaw.github.io/apis-core/
MIT License
11 stars 3 forks source link

Error 1064, "You have an error in your SQL syntax #161

Closed martinantonmueller closed 4 years ago

martinantonmueller commented 4 years ago

I try to find all Schnitzlers that are related to Munich.

Browse Person > Name or Label of person > "Schnitzler" and >related entity > "München" gives me the following error:

Request Method: GET

https://pmb.acdh.oeaw.ac.at/apis/entities/entity/person/list/?name=schnitzler&gender=&start_date_after=&start_date_before=&end_date_after=&end_date_before=&profession=&title=&related_entity_name=m%C3%BCnchen&related_relationtype_name=&Filter=Filter 2.1.2 ProgrammingError (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (SELECT apis_metainfo_tempentityclass.id, `apis_metainfo_tempentitycla' at line 1") /var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/connections.py in query, line 224 /usr/bin/python3 3.6.8 ['/var/www/html/apis-webpage-base', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/var/www/html', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf', '/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/odf'] Di, 10 Dez 2019 08:49:49 +0000

Environment:

Request Method: GET Request URL: https://pmb.acdh.oeaw.ac.at/apis/entities/entity/person/list/?name=schnitzler&gender=&start_date_after=&start_date_before=&end_date_after=&end_date_before=&profession=&title=&related_entity_name=m%C3%BCnchen&related_relationtype_name=&Filter=Filter

Django Version: 2.1.2 Python Version: 3.6.8 Installed Applications: ['dal', 'dal_select2', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'reversion', 'reversion_compare', 'crispy_forms', 'django_filters', 'django_tables2', 'rest_framework', 'webpage', 'browsing', 'django_extensions', 'apis_core.apis_entities', 'apis_core.apis_metainfo', 'apis_core.apis_relations', 'apis_core.apis_vocabularies', 'apis_core.apis_labels', 'rest_framework.authtoken', 'rest_framework_swagger', 'drf_yasg', 'guardian', 'charts', 'infos'] Installed Middleware: ['corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'reversion.middleware.RevisionMiddleware']

Traceback:

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute

  1. return self.cursor.execute(sql, params)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py" in execute

  1. return self.cursor.execute(query, args)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/cursors.py" in execute

  1. res = self._query(query)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/cursors.py" in _query

  1. db.query(q)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/connections.py" in query

  1. _mysql.connection.query(self, query)

The above exception ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (SELECT apis_metainfo_tempentityclass.id, `apis_metainfo_tempentitycla' at line 1")) was the direct cause of the following exception:

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/views/generic/base.py" in view

  1. return self.dispatch(request, *args, **kwargs)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/contrib/auth/mixins.py" in dispatch

  1. return super().dispatch(request, *args, **kwargs)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch

  1. return handler(request, *args, **kwargs)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/views/generic/list.py" in get

  1. context = self.get_context_data()

File "/var/www/html/apis-webpage-base/apis_core/apis_entities/views.py" in get_context_data

  1. context = super(GenericListViewNew, self).get_context_data()

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django_tables2/views.py" in get_context_data

  1. context = super(SingleTableMixin, self).get_context_data(**kwargs)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/views/generic/list.py" in get_context_data

  1. paginator, page, queryset, is_paginated = self.paginate_queryset(queryset, page_size)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/views/generic/list.py" in paginate_queryset

  1. page = paginator.page(page_number)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/paginator.py" in page

  1. number = self.validate_number(number)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/paginator.py" in validate_number

  1. if number > self.num_pages:

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/utils/functional.py" in get

  1. res = instance.dict[self.name] = self.func(instance)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/paginator.py" in num_pages

  1. if self.count == 0 and not self.allow_empty_first_page:

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/utils/functional.py" in get

  1. res = instance.dict[self.name] = self.func(instance)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/core/paginator.py" in count

  1. return self.object_list.count()

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/models/query.py" in count

  1. return self.query.get_count(using=self.db)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in get_count

  1. number = obj.get_aggregation(using, ['count'])['count']

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in get_aggregation

  1. result = compiler.execute_sql(SINGLE)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql

  1. cursor.execute(sql, params)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/utils.py" in execute

  1. return super().execute(sql, params)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/utils.py" in execute

  1. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute_with_wrappers

  1. return executor(sql, params, many, context)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute

  1. return self.cursor.execute(sql, params)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/utils.py" in exit

  1. raise dj_exc_value.with_traceback(traceback) from exc_value

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute

  1. return self.cursor.execute(sql, params)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py" in execute

  1. return self.cursor.execute(query, args)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/cursors.py" in execute

  1. res = self._query(query)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/cursors.py" in _query

  1. db.query(q)

File "/var/www/html/apis-webpage-base/myenv/lib/python3.6/site-packages/MySQLdb/connections.py" in query

  1. _mysql.connection.query(self, query)

Exception Type: ProgrammingError at /apis/entities/entity/person/list/ Exception Value: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (SELECT apis_metainfo_tempentityclass.id, `apis_metainfo_tempentitycla' at line 1")

SteffRhes commented 4 years ago

This bug I have fixed already but it seems that my changes were not pushed to production. The relevant commit is: 7c7d6615 in master https://gitlab.com/acdh-oeaw/apis/apis-core/commit/7c7d66150e2142975aa72f0f49bcc821d2bdfb7d

sennierer commented 4 years ago

pushed now and running; closing