Opened 6 years ago

Closed 6 years ago

#29847 closed Bug (fixed)

Window function test failures with MySQL 8

Reported by: Tom Forbes Owned by: Tom Forbes
Component: Database layer (models, ORM) Version: 2.1
Severity: Normal Keywords:
Cc: Tom Forbes Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With the mysql:8 Docker image I get the following failures on master:

FAIL: test_lag (expressions_window.tests.WindowFunctionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/lib/python3.7/unittest/case.py", line 615, in run
    testMethod()
  File "/tests/django/tests/expressions_window/tests.py", line 211, in test_lag
    ], transform=lambda row: (row.name, row.salary, row.department, row.lag))
  File "/tests/django/django/test/testcases.py", line 975, in assertQuerysetEqual
    return self.assertEqual(list(items), values, msg=msg)
  File "/usr/local/lib/python3.7/unittest/case.py", line 839, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/local/lib/python3.7/unittest/case.py", line 1045, in assertListEqual
    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
  File "/usr/local/lib/python3.7/unittest/case.py", line 1027, in assertSequenceEqual
    self.fail(msg)
  File "/usr/local/lib/python3.7/unittest/case.py", line 680, in fail
    raise self.failureException(msg)
AssertionError: Lists differ: [('Jones', 45000, 'Accounting', 45000), ('Ad[400 chars]000)] != [('Williams', 37000, 'Accounting', None), ('[400 chars]000)]
======================================================================
FAIL: test_lead (expressions_window.tests.WindowFunctionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/lib/python3.7/unittest/case.py", line 615, in run
    testMethod()
  File "/tests/django/tests/expressions_window/tests.py", line 400, in test_lead
    ], transform=lambda row: (row.name, row.salary, row.department, row.hire_date, row.lead))
  File "/tests/django/django/test/testcases.py", line 975, in assertQuerysetEqual
    return self.assertEqual(list(items), values, msg=msg)
  File "/usr/local/lib/python3.7/unittest/case.py", line 839, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/local/lib/python3.7/unittest/case.py", line 1045, in assertListEqual
    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
  File "/usr/local/lib/python3.7/unittest/case.py", line 1027, in assertSequenceEqual
    self.fail(msg)
  File "/usr/local/lib/python3.7/unittest/case.py", line 680, in fail
    raise self.failureException(msg)
AssertionError: Lists differ: [('Williams', 37000, 'Accounting', datetime.[726 chars]one)] != [('Jones', 45000, 'Accounting', datetime.dat[726 chars]one)]
First differing element 0:

Change History (4)

comment:1 by Tim Graham, 6 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 by Tom Forbes, 6 years ago

Cc: Tom Forbes added
Owner: changed from nobody to Tom Forbes
Status: newassigned

comment:4 by Florian Apolloner <apollo13@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In c53af56:

Fixed #29847 -- Ensured proper ordering in queries.

Even though good databases tend to keep the result sorted by the/one
window expression and the planners are smart enough to not resort if not
required, it is not valid to rely on this.

MariaDB specifically did return whatever order it wanted, which is
completely okay. Now we sort towards the expected data for all databases.

Note: See TracTickets for help on using tickets.
Back to Top