You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently dates have to be specified as datetime.date objects but we would like to also accept date strings so that dates in assurance tests can be specified like this:
This currently fails with an AttributeError when using the test patient above to calculate age using .age_on in the dataset definition:
Traceback (most recent call last):
File "/opt/venv/bin/ehrql", line 8, in <module>
sys.exit(entrypoint())
^^^^^^^^^^^^
File "/app/ehrql/__main__.py", line 67, in entrypoint
return main(sys.argv[1:], environ=os.environ) # pragma: no cover
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/__main__.py", line 92, in main
function(**kwargs)
File "/app/ehrql/main.py", line 326, in assure
results = assurance.validate(variable_definitions, test_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/assurance.py", line 63, in validate
query_results = {
^
File "/app/ehrql/assurance.py", line 63, in <dictcomp>
query_results = {
^
File "/app/ehrql/query_engines/in_memory.py", line 32, in get_results
table = self.get_results_as_table(variable_definitions)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory.py", line 56, in get_results_as_table
col = self.visit(node)
^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory.py", line 86, in visit
value = visitor(node)
^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory.py", line 313, in visit_DateDifferenceInYears
return self.visit_binary_op_with_null(node, date_utils.date_difference_in_years)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory.py", line 203, in visit_binary_op_with_null
return self.visit_binary_op(node, handle_null(op))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory.py", line 192, in visit_binary_op
return apply_function(op, lhs, rhs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory_database.py", line 457, in apply_function
{p: fn(*[col[p] for col in columns]) for p in patients},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory_database.py", line 457, in <dictcomp>
{p: fn(*[col[p] for col in columns]) for p in patients},
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/query_engines/in_memory_database.py", line 503, in fn_with_null
return fn(*values)
^^^^^^^^^^^
File "/app/ehrql/utils/date_utils.py", line 30, in date_difference_in_years
year_diff = end.year - start.year
^^^^^^^^^^
AttributeError: 'str' object has no attribute 'year'
The text was updated successfully, but these errors were encountered:
Currently dates have to be specified as
datetime.date
objects but we would like to also accept date strings so that dates in assurance tests can be specified like this:This currently fails with an AttributeError when using the test patient above to calculate age using
.age_on
in the dataset definition:The text was updated successfully, but these errors were encountered: