Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DATETIME Support for Tables #10

Open
michaelhiiva opened this issue Nov 23, 2020 · 1 comment · May be fixed by #12
Open

Add DATETIME Support for Tables #10

michaelhiiva opened this issue Nov 23, 2020 · 1 comment · May be fixed by #12
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@michaelhiiva
Copy link
Contributor

michaelhiiva commented Nov 23, 2020

Summary

There is a combination of DATE and DATETIME used within the schema. In order to support time zones within the AGAGD usgo/agagd#131, one needs DATETIME; however, there are several instances of DATE within the database which need change in order to support Django's datetimes and time zones. Problematic, when trying to use django-tables2's DateTimeColumn, as it results in a error:

app_1  | Internal Server Error: /
app_1  | Traceback (most recent call last):
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 41, in inner
app_1  |     response = get_response(request)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
app_1  |     response = self._get_response(request)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
app_1  |     response = self.process_exception_by_middleware(e, request)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
app_1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
app_1  |   File "./agagd_core/views/core.py", line 44, in index
app_1  |     'tournaments': t_table,
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/shortcuts.py", line 30, in render
app_1  |     content = loader.render_to_string(template_name, context, request, using=using)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/loader.py", line 68, in render_to_string
app_1  |     return template.render(context, request)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/backends/django.py", line 66, in render
app_1  |     return self.template.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 207, in render
app_1  |     return self._render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 199, in _render
app_1  |     return self.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/loader_tags.py", line 177, in render
app_1  |     return compiled_parent._render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 199, in _render
app_1  |     return self.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/loader_tags.py", line 72, in render
app_1  |     result = block.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/defaulttags.py", line 322, in render
app_1  |     return nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django_tables2/templatetags/django_tables2.py", line 169, in render
app_1  |     return template.render(context={'table': table}, request=request)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/backends/django.py", line 66, in render
app_1  |     return self.template.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 207, in render
app_1  |     return self._render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 199, in _render
app_1  |     return self.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/loader_tags.py", line 63, in render
app_1  |     result = self.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/loader_tags.py", line 63, in render
app_1  |     result = self.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/loader_tags.py", line 63, in render
app_1  |     result = self.nodelist.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 990, in render
app_1  |     bit = node.render_annotated(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/base.py", line 957, in render_annotated
app_1  |     return self.render(context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/template/defaulttags.py", line 173, in render
app_1  |     len_values = len(values)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django_tables2/rows.py", line 340, in __len__
app_1  |     length = len(self.data)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/db/models/query.py", line 232, in __len__
app_1  |     self._fetch_all()
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/db/models/query.py", line 1121, in _fetch_all
app_1  |     self._result_cache = list(self._iterable_class(self))
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/db/models/query.py", line 62, in __iter__
app_1  |     for row in compiler.results_iter(results):
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 847, in results_iter
app_1  |     row = self.apply_converters(row, converters)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 832, in apply_converters
app_1  |     value = converter(value, expression, self.connection, self.query.context)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/db/backends/mysql/operations.py", line 239, in convert_datetimefield_value
app_1  |     value = timezone.make_aware(value, self.connection.timezone)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/django/utils/timezone.py", line 285, in make_aware
app_1  |     return timezone.localize(value, is_dst=is_dst)
app_1  |   File "/home/django/.local/lib/python3.7/site-packages/pytz/__init__.py", line 244, in localize
app_1  |     if dt.tzinfo is not None:
app_1  | AttributeError: 'datetime.date' object has no attribute 'tzinfo'

schema.sql - DATE

95:    `Game_Date` DATE NOT NULL,
110:    `Elab_Date` DATE NOT NULL,
116:    `legacy_updated` DATE DEFAULT NULL,
117:    `legacy_web_updated` DATE DEFAULT NULL,
125:    `renewal_due` DATE DEFAULT NULL,
126:    `join_date` DATE DEFAULT NULL,
127:    `dob` DATE DEFAULT NULL,
261:    `Elab_Date` DATE NOT NULL,
263:    `MExp` DATE NOT NULL DEFAULT '1900-01-01',
296:    `Elab_Date` DATE DEFAULT NULL,
337:    `entrydate` DATE DEFAULT NULL
343:    `Tournament_Date` DATE NOT NULL,
350:    `Elab_Date` DATE NOT NULL,

Expected Behaviour

DATE columns are converted to DATETIME columns

Notes

  • Not know what consequence a change such as this would have on the various applications which use AGAGD's database schema.
@michaelhiiva michaelhiiva added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Nov 23, 2020
@michaelhiiva michaelhiiva changed the title DATETIME Not Fully Supported for DJango Add DATETIME Support for Tables Mar 9, 2021
@vash3g
Copy link
Member

vash3g commented Apr 28, 2021

If we change to DATETIME for the specified columns will the dates write the same or will we be displaying time data with the dates?

vash3g added a commit to vash3g/usgo-sql-schemas that referenced this issue Apr 28, 2021
addressing issue usgo#10. Modifying columns to datetime from date.
@vash3g vash3g linked a pull request Apr 28, 2021 that will close this issue
@vash3g vash3g linked a pull request Apr 28, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants