salopensource / sal

Modular reporting for Endpoints
Apache License 2.0
212 stars 64 forks source link

Long search field causing error in search_maintenance #310

Open mm-johnpeterson opened 5 years ago

mm-johnpeterson commented 5 years ago

Describe the bug A clear and concise description of what the bug is. Running a Centos 7 deployment I run into an issue when trying to run search_maintenance. django.db.utils.DataError: value too long for type character varying(254)

To Reproduce Steps to reproduce the behavior:

  1. su - saluser
  2. cd sal_env
  3. source bin/activate
  4. cd sal
  5. python2.7 manage.py search_maintenance
  6. See error
    /srv/saluser/sal_env/lib/python2.7/site-packages/django/db/models/fields/__init__.py:1430: RuntimeWarning: DateTimeField SavedSearch.created received a naive datetime (2018-11-27 18:39:34.789562) while time zone support is active.
    RuntimeWarning)
    Traceback (most recent call last):
    File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
    self.execute(*args, **cmd_options)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/core/management/base.py", line 356, in execute
    output = self.handle(*args, **options)
    File "/srv/saluser/sal_env/sal/search/management/commands/search_maintenance.py", line 117, in handle
    SearchFieldCache.objects.bulk_create(search_fields)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/models/query.py", line 452, in bulk_create
    ids = self._batched_insert(objs_without_pk, fields, batch_size)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/models/query.py", line 1060, in _batched_insert
    inserted_id = self._insert(item, fields=fields, using=self.db, return_id=True)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/models/query.py", line 1043, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1054, in execute_sql
    cursor.execute(sql, params)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/srv/saluser/sal_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
    django.db.utils.DataError: value too long for type character varying(254)

Server (please complete the following information):

Client (please complete the following information): Not affected.

mm-johnpeterson commented 5 years ago

This can likely be closed. Still trying to determine what field was that long as it has since disappeared but I modified the length of search_field and search_model under search_searchfieldcache and can now run search_maintenance.

grahamgilbert commented 5 years ago

Can you PR what you did? There isn't really any reason for this to be kept to just your install.